I need the timer to be able to reset when the game ends. The Timer is set to 1:05 to count down from that value but the timer when it is supposed to reset when it runs out, it does not it just stays at 0:00. Here is the code below:
package {
import flash.display.MovieClip;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.events.ThrottleEvent;
public class MainTimer extends MovieClip {
private var currentMin:int;
private var currentSec:int;
private var oneSecondTimer:Timer = new Timer(1000,1);
public var timerHasStopped:Boolean = false;
public function MainTimer() {
// constructor code
trace("the main timer is here");
currentMin = 1;
currentSec = 5;
minBox.text = String(currentMin);
if(currentSec < 10) {
secBox.text = "0" + String(currentSec);
}else{
secBox.text = String(currentSec);
}
oneSecondTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);
oneSecondTimer.start();
}
private function onTimerComplete(event:TimerEvent):void{
currentSec = currentSec - 1;
if (currentSec < 0){
currentSec = 59;
currentMin = currentMin - 1;
}
if(currentMin < 0) {
currentMin = 0;
currentSec = 0;
}else{
oneSecondTimer.start();
}
minBox.text = String(currentMin);
secBox.text = String(currentSec);
if(currentSec < 10){
secBox.text = "0" + String(currentSec);
}
}
public function resetTimer():void{
//update our display
currentMin = 1;
currentSec = 5;
minBox.text = String(currentMin);
secBox.text = String(currentSec);
//Adjust display for seconds less than 10
if (currentSec < 10){
secBox.text = "0" + String(currentSec);
}//end if
timerHasStopped = false;
oneSecondTimer.start();
}//end function
}
}