Hi Jeff,

In the delegate class from Steve Webster, there is this line:

var fullArgs:Array = arguments.concat(self.extraArgs, [self]);

I was wondering if anyone knows why there is a reference to self passed to
the handler function. Or how might this be useful? This extra argument could
cause a problem depending upon what your hander function does with
parameters, for example if you have a function with a dynamic number of
variables.

Yeah, my Delegate class doesn't work very well for event handlers that
expect a variable number of arguments. This has caused us problems in
the past, and we have an internal version of this class that allows
you to pass a third argument to Delegate.create that prevents the
reference to self being added to the arguments list. Let me know if
this might be useful for you and I'll dig it out.

The reference to self is passed so that you have a clean and easy way
to reference the delegate function in the event handler method. This
was added mainly for the purpose of making it easy to remove event
listeners without having to keep an external reference to the delegate
functions that were created. Of course, you could just use
arguments.caller, but that's less obvious.

Cheers,

Steve

--
Steve Webster
http://dynamicflash.com
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to