[RESOLVED] Countdown timer - displaying milliseconds
Good Afternoon!
Wasn't really sure where to put this, but A3 made the most sense, despite that fact I am a collossal newbie when it comes to Flash.
What I'd like to do is create a countdown timer to a specific date, but from all the tutorials I've read, I can't seem to find one that will include milliseconds; only a Day:hour:min:sec format.
What I'd like is an Hour:min:sec:milliseconds format (the milliseconds whilst considerably pointless, is an aesthetic choice - I'm hoping the frantically changing numbers will display a sense of urgency).
Thanks in advance, any tricks or tips are greatly appreciated :hug:
I'm using Flash CS4, and the following Actionscript so far:
Actionscript Code:
var endDate:Date = new Date(2012,9,6);
var countdownTimer:Timer = new Timer(1000);
countdownTimer.addEventListener(TimerEvent.TIMER, updateTime);
countdownTimer.start();
function updateTime(e:TimerEvent):void
{
var now:Date = new Date();
var timeLeft:Number = endDate.getTime() - now.getTime();
var seconds:Number = Math.floor(timeLeft / 1000);
var minutes:Number = Math.floor(seconds / 60);
var hours:Number = Math.floor(minutes / 60);
var days:Number = Math.floor(hours / 24);
seconds %= 60;
minutes %= 60;
hours %= 24;
var sec:String = seconds.toString();
var min:String = minutes.toString();
var hrs:String = hours.toString();
var d:String = days.toString();
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;
}