Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-06-2009, 03:18 PM   PM User | #1
mmb27
New to the CF scene

 
Join Date: Feb 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mmb27 is an unknown quantity at this point
Question Need help changing a binary clock code

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
mmb27 is offline   Reply With Quote
Old 02-10-2009, 09:29 AM   PM User | #2
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Old 02-10-2009, 08:37 PM   PM User | #3
mmb27
New to the CF scene

 
Join Date: Feb 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
mmb27 is an unknown quantity at this point
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.
mmb27 is offline   Reply With Quote
Old 02-12-2009, 09:17 AM   PM User | #4
gnomeontherun
Senior Coder

 
gnomeontherun's Avatar
 
Join Date: Sep 2007
Location: Houston
Posts: 2,846
Thanks: 10
Thanked 238 Times in 229 Posts
gnomeontherun will become famous soon enoughgnomeontherun will become famous soon enough
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.
__________________
jeremy - gnomeontherun
Educated questions often get educated answers, and simple questions often get simple answers.
gnomeontherun is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:14 PM.


Advertisement
Log in to turn off these ads.