make a movie clip. inside have two layers, one called actions the other timer.
on the timer layer have a dynamic text with variable name (var:) timer.
on the actions layer have the code:
timer = 20;
countdown = function(){
timer--;
}
countdownInterval = setInterval(countdown,1000);
on the first line (timer = 20;) change the number to how long you want the timer to go for.
if you want the timer to stop counting down or if you are using in a game and are going to constantly go back and forth between frames with the timer add:
if(timer<0){
clearInterval(countdownInterval);
}
if you add after timer--;:
if(timer<0){
clearInterval(countdownInterval);
_root.gotoAndPlay(6);
}
it will go to frame 6(or what ever else you want it to go to) when the timer gets below 0.
on the timer layer have a dynamic text with variable name (var:) timer.
on the actions layer have the code:
timer = 20;
countdown = function(){
timer--;
}
countdownInterval = setInterval(countdown,1000);
on the first line (timer = 20;) change the number to how long you want the timer to go for.
if you want the timer to stop counting down or if you are using in a game and are going to constantly go back and forth between frames with the timer add:
if(timer<0){
clearInterval(countdownInterval);
}
if you add after timer--;:
if(timer<0){
clearInterval(countdownInterval);
_root.gotoAndPlay(6);
}
it will go to frame 6(or what ever else you want it to go to) when the timer gets below 0.