|
-
Need Help With Code!!
Could anyone help me with this Countdown code, I have followed a tutorial exactly and it still comes out wrong.
Basicaly I have created a dynamic textbox on an unlabled layer I have embded the fonts and labled the text box "time_txt" then added a new layer and labled it "actions" then on the first slot I've added the code as follows:
this.onEnterFrame = function() {
var today ate = new Date();
var currentYear = today.getFullYear();
var currentTime = today.getTime();
var targetDate ate = new Date(currentYear,9,24);
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;
}
I want it to count down to 24/09/2007 (the date season 2 of Heroes is out)
Hope someone can help.
Max
-
FK'n_dog
have tested and your code is fine
the only reason for failure can be no instance name on textfield
fwiw to prevent seeing Smilies in your code when posting,
enclose the text with - [ CODE ][ /CODE ] (# icon in advanced post mode) -
Code:
var today:Date = new Date();
var currentYear = today.getFullYear();
var currentTime = today.getTime();
var targetDate:Date = new Date(currentYear,9,24);
var targetTime = targetDate.getTime();
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|