PDA

View Full Version : countdown without using getTimer..


phinnycupcakes
12-15-2008, 07:35 PM
I want to make a countdown that does not use getTimer.

It's basically for a racing game. theres a few frames where it says Get Ready, then it has the frame where a timer counts down from 5 to 0, then it goes to the next few frames that say GO!. Thing is,I want this to repeat.and GetTimer uses the time passed since the moviestarted.

This is what I have for the countdown part.

var theend = 6;
onEnterFrame = function(){
if(thetime.text != 0 )
thetime.text = theend - Math.ceil(getTimer()/1000);
else
gotoAndPlay(10);
}

and I also have another layer in that frame that resets the text to 6.

SO! If there is a reset timer method or something to help me out, let me know =D

phinnycupcakes
12-16-2008, 04:11 AM
Never mind. I think I found something that works

// Author: senocular.com
// http://www.kirupa.com/developer/actionscript/setinterval2.htm

displayTime = 10;
countDown = function () {
displayTime--;
if (displayTime == 0) {
clearInterval(timer);
}
};
timer = setInterval(countDown, 1000);

Any objections?

CyanBlue
12-16-2008, 05:46 AM
Howdy and Welcome... :)

That seems to be the one you are looking for...

phinnycupcakes
12-16-2008, 07:06 PM
It doesnt seem to work.

displayTime = 6;
timer = setInterval(countDown, 1000);

onEnterFrame = function(){
countDown();
}

countDown = function () {
displayTime--;
countdown.text = displayTime;
if (displayTime == 0) {
clearInterval(timer);
gotoAndPlay(11);
}
};


This is what I have so far. I have "countdown" linked to a dynamic text. It's not doing anything with the timer, it's just counting down the displayTime as fast as the movie goes.

Also, I joined these boards in april.. dont really need a welcome =P

-------------EDIT-------------

hopefully it shows an attached file. It's a really simple .fla that I hope one of you can help me with. I made this in Flash MX 2004 professional (meaning AS2). Remember. I want it to be able to repeat!

Bunney lord
12-23-2008, 04:51 AM
take out the onEnterFrame and it should work.