
Код AS3:
package {
import flash.utils.setTimeout;
public function mySetTimeout(closure:Function, delay:Number, ...paramets):uint {
var to:Timeout = new Timeout( closure, paramets );
to.id = setTimeout( to.call, delay );
return to.id;
}
}
import flash.utils.clearTimeout;
internal final class Timeout {
public function Timeout(closure:Function, args:Array=null) {
super();
this.closure= closure;
this.args = args;
}
public var id:uint;
public var closure:Function;
public var args:Array;
public function call():void {
clearTimeout( this.id );
this.closure.apply( null, this.args );
}
}
Добавлено через 1 минуту
expl, зато я смогу определять есть ли такой таймаут по значению 0.