chrisiek
chrisiek

Reputation: 97

removing timer is not working

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

Upvotes: 1

Views: 333

Answers (2)

Joe
Joe

Reputation: 82614

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?

Upvotes: 0

Nathan Villaescusa
Nathan Villaescusa

Reputation: 17639

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

Upvotes: 4

Related Questions