手机
当前位置:查字典教程网 >网页设计 >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 AS 入门教程 乱数排列(随机数)方法

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

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

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

Flash MX过程中使用3个小技巧分享

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

卸载Flash插件的方法

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

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

精品推荐
分类导航