How to reset my Timer
Hello!
I have a question and I hope I can find a solution here.I have a short quiz and I want to allow the user only 30 seconds per question to give a right answer.
I have a "start" button that triggers a countdown timer for the first time. Then, I want each time the user clicks the button "next", the countdown to start again counting from 30 to 0. This is what I have tried so far:
var fl_SecondsToCountDown:Number = 30;
var fl_CountDownTimerInstance:Timer = new Timer(1000, fl_SecondsToCountDown);
fl_CountDownTimerInstance.addEventListener(TimerEvent.TIMER, fl_CountDownTimerHandler);
start_btn.addEventListener(MouseEvent.CLICK,startCountdown);
next_btn.addEventListener(MouseEvent.CLICK, goNext);
function fl_CountDownTimerHandler(event:TimerEvent):void
{
seconds_txt.text = String(fl_SecondsToCountDown);
fl_SecondsToCountDown--;
}
function startCountdown(e:MouseEvent):void{
fl_CountDownTimerInstance.start();
}
function goNext(e:MouseEvent):void{
fl_CountDownTimerInstance.reset();
}
Now, what it does it's just stopping the countdown at 25 seconds, for example, and then if I ask it to start again, it starts where it has left off, instead of going back to 30 seconds again.
Thanks a lot!