Improved Delegate
The Delegate class has existed for some time. We just added a little twist to it. Our version Delegate (com.bigspaceship.utils.Delegate) does everything that Adobe’s does, but also allows for additional custom arguments.
myMovieClip.onEnterFrame = Delegate.create(this,_onEnterFrame,"hello world");
function _onEnterFrame($str:String):Void {
trace($str); // will output "hello world"
};
You can take a look at our version of this here.
If the function you’ve delegated comes with pre-existing arguments they immediately get tacked to the end of your targeted function. For example:
var x = new XML();
x.onLoad = Delegate.create(this, _onXMLLoad, x, "hello world");
x.load("foo.xml");
function _onXMLLoad($x:XML, $str:String, $success:Boolean):Void {
trace($str + “: ” + $x + “: ” + $success);
// will output “hello world” along with your XML object and success boolean.
};
You can read more about Proxying Events here.




