PDA

View Full Version : Creating a countdown timer


IMDjinx
12-06-2004, 10:17 AM
Hey anyone have any idea of how to create a countdown timer independant of the time line?

We are creating an interactive project which jumps from one end of the time line to the other and back again while we have some music playing (it starts in Frame 1 and then never returns to Frame one even if it returns several times to Frame 2). So we need a way of stopping the game/intractive movie when the song has finished but without relying on it ever reaching the last frame of the song to do so.

Any ideas as to how to do this then it would be much apreciated.

IMDjinx :confused:

cancerinform
12-06-2004, 04:29 PM
Here is an example. Go to the memory game. The timer will stop, if the game is finished. Everything is in one frame though but should be applicable to multiple frames. This is OOP Gametimer class and the stop of the countdown is achieved by a separate function, which fires a Boolean, which then stops the countdown.

http://www.flashscript.biz/MX2004/speech/speech.html

IMDjinx
12-07-2004, 09:19 AM
Thanks thats what I need but how do you see the scripting for it? :confused:

cancerinform
12-07-2004, 10:29 AM
This is part of the timer class script calling the countdown function which has an interval function:

class Simpletimer extends MovieClip {
.....
public function recordTime (n_onePlayer, downTime) {
.....
o_myPause.interval = function() {
if (m_timer.stopGameNow) {
clearInterval(nu_myTimer);
m_timer.stopGameNow = false;
}
.....
nu_myTimer = setInterval(o_myPause, "interval", 1000);
.....

then there is a separate function in the same class:

public function stopGame () {
var m_timer:MovieClip = timer;
timer.stopGameNow = true;
};

_____________________________
in the movie at one point the stop function will be called:

......
if (myScore == 6) {
//function to stop the game
gTi.stopGame();//gTi is an instance of the timer
}
.....