删除计时器不起作用
如何正确删除/停止动作脚本中的计时器?
我在这段代码中这样做,但计时器已设置为在 200 秒后触发frame1SoundTimerHandler:
playingScreenFramesObj.myTimer2.stop();
playingScreenFramesObj.myTimer2.removeEventListener(TimerEvent.TIMER, frame1SoundTimerHandler);
playingScreenFramesObj.myTimer2 = null;
似乎尽管使用上面的代码停止/删除计时器,处理程序仍将在 200 秒内运行。
我的错误在哪里?
克里斯
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你应该只需要调用timer.stop()。作为故障保护,您始终可以从事件处理程序内部检查timer.running。
You should only have to call timer.stop(). As a failsafe you could always check timer.running from inside the event handler.
该代码应该可以工作。您确定您在正确的计时器上停止了吗?例如,您是否可能不小心使用了timer1并停止了timer2?
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?