Universal timer across multiple frames
Hello again
I'm creating a flash quiz and each question is timed. When the timer runs out I have some actionscript that says 'when timer reaches 0, go to and stop frame x', but the problem is I have quite a few pages and some of my timers are conflicting. Is there a way I can make one timer control everything?
At the moment I have one timer that controls when the clock times out
var count:Number = 6;
var myTimer:Timer=new Timer(1000,count);
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();
function countdown(event:TimerEvent):void {
myText_txt.text=String((count)-myTimer.currentCount);
if(myText_txt.text == "0"){
gotoAndStop(5);
}
}
I have 'correct' and 'incorrect' pages, so when a question a question is answered correctly, you will jump to the 'correct' frame on the timeline. I then have a timer that controls when you leave that page
Example
var myTimer2:Timer;
myTimer2 = new Timer(3000, 3)
myTimer2.start();
myTimer2.addEventListener(TimerEvent.TIMER, backtoStart2)
function backtoStart2(evt:TimerEvent):void{
myTimer2.start();
if(myTimer2.currentCount == 3) (gotoAndStop(3));
trace (myTimer2.currentCount)
}
My problem is that I have 8 questions, and it seems silly to make a new timer for each page, especially when I will keep getting a duplicate function definition error. What is the best way to approach this if I want all my actionscript on one frame?