...

View Full Version : Need help changing a binary clock code



mmb27
02-06-2009, 03:18 PM
I am working with a code for a binary clock, I am wanting to change the format from 24 hour to 12 hour. I am pretty new to flash so please bear with my ignorance:(. I have an idea of which line of code I need to change, but am unclear on exactly what to change it to so that the time displays correctly. Here is the code that I am working with:

this.onEnterFrame = function ()
{
d = new Date();
h = d.getHours();
hh = int(h / 10);
h = h % 10;
hh1.setValue(hh & 2);
hh0.setValue(hh & 1);
h3.setValue(h & 8);
h2.setValue(h & 4);
h1.setValue(h & 2);
h0.setValue(h & 1);
m = d.getMinutes();
mm = int(m / 10);
m = m % 10;
mm2.setValue(mm & 4);
mm1.setValue(mm & 2);
mm0.setValue(mm & 1);
m3.setValue(m & 8);
m2.setValue(m & 4);
m1.setValue(m & 2);
m0.setValue(m & 1);
s = d.getSeconds();
ss = int(s / 10);
s = s % 10;
ss2.setValue(ss & 4);
ss1.setValue(ss & 2);
ss0.setValue(ss & 1);
s3.setValue(s & 8);
s2.setValue(s & 4);
s1.setValue(s & 2);
s0.setValue(s & 1);
};

Thank you for any help you may be able to offer me, or any resources you any be able to direct me towards.

Matt

gnomeontherun
02-10-2009, 09:29 AM
Well I hope you are running this movie at a frame rate of only 1 or 2, otherwise you would have a LOT of extra processing going on.

http://www.webwasp.co.uk/tutorials/a29-clock/index.php Here is a nice tutorial to explain it.

mmb27
02-10-2009, 08:37 PM
Thanks for the response. I can code analog and digital clocks with out any problems. My problem lies within the binary styled one I am working on, currently it displays in the 24 hr mode and I need it to only show in 12 hours. I just can't figure out how exactly to change the coding to reflect the change.

gnomeontherun
02-12-2009, 09:17 AM
What does this code output as it is?

Ideally you would get the hour, add 1, test it if it is over 12, and if so subtract 12 and you could even set a variable to be am or pm depending on if the test is over 12.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum