Copy link to clipboard
Copied
1). This timer was designed to wait for the cation on stage to be finished and then to go to the next frame. The problem is that in the 'function finishMove' each condition runs only after the previous condition completed the full timer's cycle. so the first removeChild(gdropBall2); happens immediately, but removeChild(Wall2Missing); get deleted 2 seconds later and the last removeChild(gdropBall1); get deleted 2 seconds after that. I want it all happened at the same time. How do I do that?
2). the function stopTimer was supposed to stop the timer but I'm not sure that it does, I had to put the conditions in 'function finishMove' because it errors on Child not found after it's been removed in the first timer's cycle.
'var timer2: Timer = new Timer(2000);
timer2.addEventListener(TimerEvent.TIMER, finishMove);
function checkScoreScene10(): void {
if (scoreScene10 >= 300) {
timer2.start();
}
}
function finishMove(e: TimerEvent): void {
if (stage.contains(gdropBall2)) {
removeChild(gdropBall2);
} else if (stage.contains(Wall2Missing)) {
removeChild(Wall2Missing);
} else if (stage.contains(gdropBall1)) {
removeChild(gdropBall1);
gotoAndStop(2);
}
function stopTimer(event: TimerEvent): void {
timer2.removeEventListener(TimerEvent.TIMER, stopTimer);
timer2 = null;
}
}'
Copy link to clipboard
Copied
Try using 3 separate if conditional statements instead of 1 if and 2 else-if conditional statements.
It looks like you inadvertently defined your stopTimer function inside your finishMove function.
You'll probably want to use the stop method of the Timer class in addition to removing your listener.