as3 手续延缓执行的办法分享

更新时间:15-10-22 23:00 热度:375



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(门里出身, params);
if (timer.currentcount == repeat)
timer.removeeventlistener(timerevent.timer, f);
timer = 门里出身;