So, I have this timer in 2 scenes. The timer in the 1st scene works perfectly. However, when I tried it to the 2nd scene the timer goes so fast.
I have 2 set of codes:
_root.timer = 10;
clearInterval(id);
id = setInterval (function ()
{
_root.timer--;
if(timer==0)
{
gotoAndStop(65);
}
}, 1000);
AND this:
timer = 10;
timer.text= timer;
countdown = function(){
timer--;
if(timer==0){
clearInterval(countdownInterval);
gotoAndStop(65);
}
}
countdownInterval = setInterval(countdown,1000);
I’m aware that 1000 milliseconds = 1 second. I just don’t know what causes the timer to decrease fast in the second scene. What do you think?
In the second scene, timer decrase 2 times faster, because there is two setInterval running, _root.timer will equal timer in two stages. So there is two functions calling each second, and it each function decrases same variable.
Solution: in second scene, rename timer variable to timer2 or timernew.