
Код AS3:
package utils {
public function nextFrameCall(func:Function, ...args) {
new Listener(func, args);
}
}
import flash.display.Shape;
import flash.events.Event;
/**
* @private
*/
internal final class Listener {
public function Listener(listener:Function, args:Array) {
super();
this._listener = listener;
this._args = args;
enterFrameBroadcaster.addEventListener(Event.ENTER_FRAME, this.handler);
}
/**
* @private
*/
private var _listener:Function;
/**
* @private
*/
private var _args:Array;
/**
* @private
*/
private function handler(event:Event) {
enterFrameBroadcaster.removeEventListener(event.type, arguments.callee);
this._listener.apply(null, this._args);
}
}
/**
* @private
*/
internal const enterFrameBroadcaster:Shape = new Shape();