This is for a countdown. Can anyone tell me what is wrong with it? I get 5
errors when I try to veiw it.
this.onEnterFrame = function() {
var today:Date = new Date();
var currentYear = today.getFullYear();
var currentTime = today.getTime();
var targetDate:Date = new Date(currentYear,6,31);
var targetTime = targetDate.getTime();
var timeLeft = targetTime - currentTime;
var sec = Math.floor(timeLeft/1000);
var min = Math.floor(sec/60);
var hrs = Math.floor(min/60);
var days = Math.floor(hrs/24);
sec = string(sec % 60);
if sec.length < 2) {
sec = "0" + sec;
}
min = string(min % 60);
if min.length < 2) {
min = "0" + min;
}
hrs = string(hrs % 24);
if hrs.length < 2) {
hrs = "0" + hrs;
}
days = string(days);
var = counter:String = days + ":" + hrs + ":" + min + ":" + sec;
time_txt.text = counter;
}
Noelbaland - 10 Jul 2008 06:51 GMT
Hello,
Basically just syntax errors. Should work once you fix the errors below.
1) You have missing opening "(" brace in 3 of your if statements.
if sec.length < 2) {
sec = "0" + sec;
}
should be
if (sec.length < 2) {
sec = "0" + sec;
}
Same thing with min and hrs
2) Uppercase S needed in String function
sec = string(sec % 60);
should be
sec = String(sec % 60);
Same throughout script
3) Can you see the last one?
var = counter:String = days + ":" + hrs + ":" + min + ":" + sec;
There are 2 "=" operators. Remove the first one.
just started - 10 Jul 2008 15:40 GMT
Thank you. I knew it had to be simple!