1

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

2 Answers 2

4

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

2
  • Your solution looks nice for debugging but how do I access running parameter from inside event handler?
    – chrisiek
    May 20, 2011 at 22:04
  • You should be able access the timer as event.target, you may need to cast it to the correct type. Jun 1, 2011 at 14:27
0

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.