手机
当前位置:查字典教程网 >网页设计 >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制作GIF完整分享

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

FLASH中响应键盘事件的方法

Flash CS4教程:制作质感的水晶泡泡动画

卸载Flash插件的方法

用flash实现手写输入方法

AS3 结合基本的动画和AS3绘图API

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

精品推荐
分类导航