加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex – Timer与setTimeout

发布时间:2020-12-15 02:17:11 所属栏目:百科 来源:网络整理
导读:flash.utils.setTimeout()的文档状态: Instead of using this method,consider creating a Timer object,with the specified interval,using 1 as the repeatCount parameter (which sets the timer to run only once). 有谁知道这样做有(重要)优势吗?当您
flash.utils.setTimeout()的文档状态:

Instead of using this method,consider
creating a Timer object,with the
specified interval,using 1 as the
repeatCount parameter (which sets the
timer to run only once).

有谁知道这样做有(重要)优势吗?当您只需要延迟1次调用时,使用setTimeout会更容易.

解决方法

setTimeout实际上使用一个Timer子类,即SetIntervalTimer,它是一个内部类.你可以通过做setTimeout(function():void {th??row“booom”;},1);.你会在堆栈跟踪中看到它.

因此,我看不出很大的劣势.唯一的区别是,你有2个匿名电话而不是一个. OTOH,在性能严峻的情况下,您不应该使用(除了一个内部定时器)以避免频繁实例化TimerEvent对象.

基本上,我认为这是一个味道的问题. Adobe决定,AS3事件系统是嘶嘶声,所以他们推广它.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读