Help me about AS3 code of 24 hour countdown timer.
Hi,
I'm a beginner at flash.
i just wanna ask about making 24hours countdown clock.
what i want is to make it only 24hour countdown clock and when it reaches the time it will start again.(every day)
and The start time is 2 o'clok(2 pm) every single day.(for the pacific time)
and I found this code from (http://forums.adobe.com/message/4116774 )
It's similar with what i want but even I tried, I can't change for mind...
and I want using hundredths too.
so here is the code.
Please help me,Thank you.
-----------------------------------------------
var endDate:Date = new Date(new Date().getTime()+24*60*60*1000);
var countdownTimer:Timer = new Timer(1000);
countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
countdownTimer.start();
function updateTime(e:TimerEvent):void
{
var now:Date = new Date();
if(now.getTime()>endDate.getTime()){
time_txt.text = "00:00:00";
countdownTimer.stop();
return
}
var timeLeft:Number = endDate.getTime() - now.getTime();
var hundredth:Number = Math.floor(timeLeft / 10);
var seconds:Number = Math.floor(hundredth / 1000);
var minutes:Number = Math.floor(seconds / 60);
var hours:Number = Math.floor(minutes / 60);
seconds %= 60;
minutes %= 60;
var fs:String = hundredth.toString();
var sec:String = seconds.toString();
var min:String = minutes.toString();
var hrs:String = hours.toString();
if (fs.length < 2) {
sec = "0" + fs;
}
if (sec.length < 2) {
sec = "0" + sec;
}
if (min.length < 2) {
min = "0" + min;
}
if (hrs.length < 2) {
hrs = "0" + hrs;
}
var time:String = hrs + ":" + min + ":" + sec;
time_txt.text = time;
}
