getting a timer to continue after returning to frame where it was created/started
In my boredom I am trying to create the contestant podiums from Sale of The Century and have them set up to look like the TV show (see here: https://youtu.be/rZSdhRZQjak?t=25s). Now this is done between 5 frames on the timeline (with a different graphic for each frame. Everything is fine and swell until I added a timer for the speed round. I created a dynamic TextField in Flash. The problem is that every time I reset the podium by using the gotoAndStop method, my timer stops as well. I tried moving the textfield (because I have to have a removeChild method as it was created in flash) and the gotoAndStop but that still causes issues. I tried by creating the textfield in AS, but I just got the empty rectangle. Below is the code from the frame that is the default podium position and where the timer is created.
The question is how do I get the timer to continue to run after I had gone through the player "buzzin" frames and back to the default?
stop();
removeChild(srclock_txt);
pScore1.text = (firstPlayerScore).toString();
pScore2.text = (secondPlayerScore).toString();
pScore3.text = (thirdPlayerScore).toString();
pName1.text = firstPlayer;
pName2.text = secondPlayer;
pName3.text = thirdPlayer;
var leftArrow: Boolean = false;
var rightArrow: Boolean = false;
var upArrow: Boolean = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, buzzin);
function buzzin(event: KeyboardEvent): void {
trace(event.keyCode);
if (event.keyCode == 37) {
leftArrow = true;
gotoAndPlay(4);
} else if (event.keyCode == 39) {
rightArrow = true;
gotoAndPlay(14);
} else if (event.keyCode == 38) {
upArrow = true;
gotoAndPlay(9);
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, give_me_60);
function give_me_60(event: KeyboardEvent): void {
var clock_back: Shape = new Shape();
clock_back.graphics.beginFill(0x000000);
clock_back.graphics.lineStyle(3, 0xff0000);
clock_back.graphics.drawRect(262.5, 312.4, 52, 40.6);
clock_back.graphics.endFill();
if (event.keyCode == 84) {
addChild(clock_back);
addChild(srclock_txt);
}}
var countDownDec:Number =1;
var totalSecs = 10;
var countDownSecs = totalSecs;
srclock_txt.text = countDownSecs;
var myTimer:Timer = new Timer (countDownDec*1000);
myTimer.addEventListener(TimerEvent.TIMER, tick);
function tick (e:TimerEvent): void {
if (countDownSecs == 0) {
myTimer.stop ();
} else {
countDownSecs = countDownSecs - countDownDec;
srclock_txt.text = countDownSecs;
}}
stage.addEventListener(KeyboardEvent.KEY_DOWN, start_clock);
function start_clock (event:KeyboardEvent): void {
if (event.keyCode == 71) {
srclock_txt.text = totalSecs;
myTimer.start();
}}
stage.addEventListener(KeyboardEvent.KEY_DOWN, stop_clock);
function stop_clock (event:KeyboardEvent): void {
if (event.keyCode == 83) {
myTimer.stop();
}
}
