手机
当前位置:查字典教程网 >网页设计 >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程序的测试方法

Flash AS3.0打造漂亮的水纹GIF动画效果

Flash绘制卡通人物眨眼动画的方法及技巧

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

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

Flash教程:卡通人物基本五官造型和绘制方法

Flash AS 入门教程 圆和椭圆函数的应用

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

Flash动画技巧 坐标的计算方法

精品推荐
分类导航