手机
当前位置:查字典教程网 >网页设计 >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 程序延迟执行的方法分享】相关文章:

ActionScript3.0中建立帧频计数器的方法

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

flash场景之间相互跳转的实现方法

教你用FLASH画天天连萌中的绿小兔

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

Flash片头加载loading的制作方法

Flash CS3教程:模糊运动制作飞行文字

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

Flash绿色版打开提示Java出现错误的解决方法

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

精品推荐
分类导航