手机
当前位置:查字典教程网 >网页设计 >Flash教程 >AS3 程序延迟执行的方法分享
AS3 程序延迟执行的方法分享
摘要:复制代码代码如下:importflash.events.TimerEvent;importflash.utils.Timer;/***del...

复制代码代码如下:

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 程序延迟执行的方法分享】相关文章:

Flash制作电影序幕的文字动画效果

Flash中如何调用exe可执行文件?

Flash cs5元件怎么制作?按钮元件的制作方法

Flash AS教程:填色游戏的制作

使用Flash制作牛丑丑的表情 Flash制作GIF完整分享

卸载Flash插件的方法

造成Flash动画文件增大原因与解决的方法

Flash AS3.0实例教程:鼠标感应发光的文字旋转效果

Flash CS4方块形状的动画特效制作

网页中Flash激活限制的处理方法

精品推荐
分类导航