我是靠谱客的博主 纯真小丸子,这篇文章主要介绍AS3 程序延迟执行的方法分享,现在分享给大家,希望可以做个参考。


复制代码
代码如下:

import flash.events.TimerEvent;
import flash.utils.Timer;

/**
* delay function
* a quick and easy delay function that can call a function with parameters. configurable
* with delay time and repeat frequency
*
* @param func:Function The function to call when timer is complete
* @param params:Array An array of parameters to pass to the function
* @param delay:int [OPTIONAL] The number of milliseconds to wait before running the function
* @param repeat:int [OPTIONAL] The number of times the function should repeat
*/
private function delay(func:Function, params:Array, delay:int = 350, repeat:int = 1):void
{
var f:Function;
var timer:Timer = new Timer(delay, repeat);
timer.addEventListener(TimerEvent.TIMER, f = function():void
{
func.apply(null, params);
if (timer.currentCount == repeat)
{
timer.removeEventListener(TimerEvent.TIMER, f);
timer = null;
}
});
timer.start();
}

最后

以上就是纯真小丸子最近收集整理的关于AS3 程序延迟执行的方法分享的全部内容,更多相关AS3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(180)

评论列表共有 0 条评论

立即
投稿
返回
顶部