Skip to main content
Known Participant
August 26, 2010
Answered

how to reset timer back to zero?

  • August 26, 2010
  • 1 reply
  • 649 views

Good day people,

how to reset timer back to zero?

I have a button in the parent timeline of the code below and when I click it I want the behavior of the time will go back to 1 or 0.

Button clicked, timer back to 1 or 0.

-----------------------------------

contents_mc - timer_txt

-----------------------------------

_root.elapseTime = 0;

intervalId = setInterval(this,"countDown",1000);

function countDown(){

if(_root.timerOn){

_root.elapseTime++;

_time = _root.elapseTime + " Sekunden";

if(_root.elapseTime == 10){

_parent.gotoAndStop("GameOutOfTime");

clearInterval(intervalId);

}

}

}

stop();

Any reply will be appreciated,

Thanks

This topic has been closed for replies.
Correct answer kglad

use:

function resetF():Void{

clearInterval(intervalID);

intervalId = setInterval(countDown,1000);

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 26, 2010

use:

function resetF():Void{

clearInterval(intervalID);

intervalId = setInterval(countDown,1000);

}

Known Participant
August 26, 2010

Thanks Mr. kglad,

It takes almost 6 hours for me to get the code to run.

What I did was I just put the _root.elapseTime = 0 into the very button and it works!

Just as I wanted it to be.

kglad
Community Expert
Community Expert
August 26, 2010

you're welcome.