删除计时器不起作用 [英] removing timer is not working

查看:30
本文介绍了删除计时器不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在动作脚本中正确删除/停止计时器?

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

我像在这段代码中那样做,但计时器已设置为在 200 秒后触发 frame1SoundTimerHandler :

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;

似乎尽管使用上面的代码停止/删除计时器,但处理程序仍将在 200 秒内运行.

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

我犯的错误在哪里?

克里斯

推荐答案

你应该只需要调用 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.

这篇关于删除计时器不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆