Help me about AS3 code of 24 hour countdown timer.
hi,
i'm beginner @ flash.
i wanna ask making 24hours countdown clock.
what want make 24hour countdown clock , when reaches time start again.(every day)
and start time 2 o'clok(2 pm) every single day.(for pacific time)
and found code (http://forums.adobe.com/message/4116774 )
it's similar want tried, can't change mind...
and want using hundredths too.
so here code.
please 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;
}
if want enddate today @ 2pm, among other ways this, can use:
var enddate:date = new date();
enddate.sethours(14);
enddate.setminutes(0);
enddate.setseconds(0);
More discussions in ActionScript 3
adobe
Comments
Post a Comment