i am using flash for pretty much the first time and am trying to make a simple file that will countdown from 4 minutes, displaying the minutes seconds and milliseconds remaining. I basically wrote the code that it would take the current time and add 4 minutes to that and then countdown from there, maybe that is the reason that it does not work, im not exactly sure about it now. im posting the code here if any of you could care to take a look at it, it will run on actionscript 2 but wont 'compile' with actionscript 3. thanks for your help ahead of time
Code:
this.onEnterFrame = function () {
var today:Date = new Date();
var currentTime = today.getTime();
var currentYear = today.getFullYear();
var currentMonth = today.getMonth();
var currentDay = today.getDay();
var currentHour = today.getHours();
var targetTime = currentTime + new Date(currentYear, currentMonth, currentDay, currentHour, 4);
var timeLeft = targetTime - currentTime;
var ms = targetTime;
var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
ms = string(ms % 1000);
if(ms.length < 2) {
ms = "0" + ms;
}
sec = string(sec % 60);
if(sec.length < 2) {
sec = "0" + sec;
}
min = string(min % 60);
if(min.length < 2) {
min = "0" + min;
}
var counter:String = min + ":" + sec + ":" + ms;
time_txt.text = counter;
}