1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
/**
* Proxy event handler, acts like mx.utils.Delegate and compatible with MTASC compiler</p>
*
* @author Younes younes@locobrain.com
* @version 1.0
* @since 2005/3/17
*
* @credit http://blog.locobrain.com
*/
class com.locobrain.events.EventDelegate {
private function EventDelegate () {}
/**
* Creates a functions wrapper that runs in the provided scope.
* @usage
* <code>
* EventDelegate.create (myObject, myEventHandler, param0,param1, [..])
* </code>
* @param scope Scope object which to run the function
* @param method Function to run
* @return Function wrapper
*/
public static function create (scope:Object, method:Function):Function {
var params:Array = arguments.splice (2, (arguments.length-2));
var proxyFunc:Function = function ():Void {
method.apply(scope, arguments.concat (params));
}
return proxyFunc;
}
} |
Partager