-
AS3 Timezone Countdown?
Hey, I'm looking for a Countdown clock with dd:hh:mm:ss
That Counts down to every Saturday at 23h ( Paris UTC+1 )
I'm really not sure how to do the Time zone thing..
Any help is greatly appreciated.
Thanks.
-
Prid - Outing
How do you want to display the countdown? Days, hours, minutes, seconds?
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Originally Posted by Nig 13
How do you want to display the countdown? Days, hours, minutes, seconds?
Yes, Say 07:24:59:59
dd:hh:mm:ss
-
does anybody know a way to do this? Any help is appreciated thank you.
-
Prid - Outing
Hi,
sorry for long delay, but I was busy with other stuff and I also had to learn the Modulus Operator (%) in order to display the time in human-readable format. Here is the code:
Actionscript Code:
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, showTime);
function showTime(e:Event){ var time:Date = new Date(); var timeZoneOffset:Number = 1; // change this to change the offset var saturday = (time.getUTCDay() < 7 ? 6-(time.getUTCDay()) : 6); var date1:Date = new Date(time.getUTCFullYear(), time.getUTCMonth(), time.getUTCDate()+saturday, 23); var date2:Date = new Date(time.getUTCFullYear(), time.getUTCMonth(), time.getUTCDate(), time.getUTCHours()+timeZoneOffset, time.getUTCMinutes(), time.getUTCSeconds(), time.getUTCMilliseconds()); var timeLeft:Number = Number(date1)-Number(date2); var milliSecondsLeft = timeLeft % 1000; var secondsLeft = Math.ceil((timeLeft/1000) % 60); var minutesLeft = Math.ceil((timeLeft/1000/60) % 60); var hoursLeft = Math.floor((timeLeft/1000/60/60) % 24); var daysLeft = Math.floor(timeLeft/1000/60/60/24); // ADD "0" IN FRONT OF NUMBERS SMALLER THAN 10 // if(secondsLeft < 10) secondsLeft = "0"+secondsLeft; if(minutesLeft < 10) minutesLeft = "0"+minutesLeft; if(hoursLeft < 10) hoursLeft = "0"+hoursLeft; ///////////////////////////////////////////////// trace(daysLeft+":"+hoursLeft+":"+minutesLeft+":"+secondsLeft+":"+milliSecondsLeft); }
If you don't want the "0" (zero) in front of numbers smaller than 10 for seconds, minutes and hours, just remove the marked area. The last line with the trace() demonstrates how you can use each of the numbers to make a visible countdown (e.g. in a text field). Just use those variables (daysLeft, hoursLeft, minutesLeft, secondsLeft, milliSecondsLeft) and implement it in any way you want.
I haven't tested if it works yet, but hopefully I will tonight (since it's Saturday today), and see if it starts counting to next Saturday after 23 o'clock, your time. If you spot any bugs, just report me them and I'll see if I can fix them.
Hope this helps
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Originally Posted by Nig 13
Hi,
sorry for long delay, but I was busy with other stuff and I also had to learn the Modulus Operator (%) in order to display the time in human-readable format. Here is the code:
Actionscript Code:
import flash.events.Event;
addEventListener(Event.ENTER_FRAME, showTime);
function showTime(e:Event){ var time:Date = new Date(); var timeZoneOffset:Number = 1; // change this to change the offset var saturday = (time.getUTCDay() < 7 ? 6-(time.getUTCDay()) : 6); var date1:Date = new Date(time.getUTCFullYear(), time.getUTCMonth(), time.getUTCDate()+saturday, 23); var date2:Date = new Date(time.getUTCFullYear(), time.getUTCMonth(), time.getUTCDate(), time.getUTCHours()+timeZoneOffset, time.getUTCMinutes(), time.getUTCSeconds(), time.getUTCMilliseconds()); var timeLeft:Number = Number(date1)-Number(date2); var milliSecondsLeft = timeLeft % 1000; var secondsLeft = Math.ceil((timeLeft/1000) % 60); var minutesLeft = Math.ceil((timeLeft/1000/60) % 60); var hoursLeft = Math.floor((timeLeft/1000/60/60) % 24); var daysLeft = Math.floor(timeLeft/1000/60/60/24); // ADD "0" IN FRONT OF NUMBERS SMALLER THAN 10 // if(secondsLeft < 10) secondsLeft = "0"+secondsLeft; if(minutesLeft < 10) minutesLeft = "0"+minutesLeft; if(hoursLeft < 10) hoursLeft = "0"+hoursLeft; ///////////////////////////////////////////////// trace(daysLeft+":"+hoursLeft+":"+minutesLeft+":"+secondsLeft+":"+milliSecondsLeft); }
If you don't want the "0" (zero) in front of numbers smaller than 10 for seconds, minutes and hours, just remove the marked area. The last line with the trace() demonstrates how you can use each of the numbers to make a visible countdown (e.g. in a text field). Just use those variables (daysLeft, hoursLeft, minutesLeft, secondsLeft, milliSecondsLeft) and implement it in any way you want.
I haven't tested if it works yet, but hopefully I will tonight (since it's Saturday today), and see if it starts counting to next Saturday after 23 o'clock, your time. If you spot any bugs, just report me them and I'll see if I can fix them.
Hope this helps
Hey thank you so vary much.
Helped me out allot.
About to go test i will let you know if it works
Thanks again.
-
Having a problem,
When I add this code and create my txt boxes.
nothing is showing up in the text boxes daysLeft, hoursLeft etc..
Also the Timezone clock you helped me with, works on a new blank project
but when I try to add it to my main project no numbers show up again.
No errors. nothing..
They are dynamic text.
Anti-alias for readability.
and all named correctly.
Hope I am making sense
-
Scratch that,
I have the Clock working.
I just cant seem to get the countdown to show up in the Text fields.
I can see it showing up in the Output box.
The text boxes are named daysLeft hoursLeft etc..
I have tryed, Changing box sizes, Font, Anti-alias, Auto kern, Format..
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|