removing timer is not working

2019-07-27 05:24发布

问题:

How do I correctly remove/stop a timer in actionscript?

I do it like in this piece of code but timer has been set to fire frame1SoundTimerHandler in 200 seconds later :

            playingScreenFramesObj.myTimer2.stop(); 
            playingScreenFramesObj.myTimer2.removeEventListener(TimerEvent.TIMER, frame1SoundTimerHandler);
            playingScreenFramesObj.myTimer2 = null;

It seems that despite stopping/removing the timer with the code above the handler will run in 200 seconds.

Where is the mistake I make?

Chris

回答1:

You should only have to call timer.stop(). As a failsafe you could always check timer.running from inside the event handler.



回答2:

That code should work. Are you positive you are calling stop on the correct timer? For example, could you accidentally be using timer1 and stopping timer2?