removing timer is not working

对着背影说爱祢 提交于 2019-12-11 08:49:30

问题


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?



来源:https://stackoverflow.com/questions/6077321/removing-timer-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!