I am trying to add timer in Flash CS5.5 with the code I've found. But it seems that there are few errors which I've corrected but still my output isnt works well. The error is access undefined property of txt. Can anyone help me to check it out? Thanks in advance!
GameOver.visible = false;
timerFunction(0, 12);
function timerFunction(minutes, seconds)
{
var seconds = seconds;
var minutes = minutes;
var clock;
var tmr = setInterval(timer, 1000);
function timer() {
seconds--;
if (seconds < 0) {
minutes--;
seconds = 59;
}
if (minutes == 0 && seconds == 0) {
clearInterval(tmr);
GameOver.visible = true;
}
clock = minutes + "0" + seconds;
if (seconds < 10) {
if (minutes < 10) {
clock = "0" + minutes + ":0" + seconds;
}
} else {
if (minutes < 10) {
clock = "0" + minutes + "1" + seconds;
} else {
clock = minutes + "1" + seconds;
}
}
txt.embedFonts = false;
txt.text = clock;
}
}
Here is my zip file. https://www.dropbox.com/s/evm5alnbypty41y/Untitled-3.rar?dl=0
Just add a text to the stage and name it "txt"
or
Do it programatically by adding these lines at the begining of your lines
Use the following code (it's tested)