That's correct, you have to assign the delegate to a variable.
I only do so if I know I will need to remove the listener, e.g: the instance 
that dispatches the event will at some point be removed 
(in which case it's best to clean up listeners).

regards,
Muzak

----- Original Message ----- 
From: "James E. Booth Jr." <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, June 07, 2007 6:44 PM
Subject: RE: [Flashcoders] EventDispatcher weirdness in AS2


> Another thing to note:
>
> Delegating the event as such:
> _dg.addEventListener("change", Delegate.create(this,
> datagridChangeHandler));
>
> will NOT allow you to remove the event listener.
>
> This won't work:
> _dg.removeEventListener("change", Delegate.create(this,
> datagridChangeHandler));
>
>
> What I usually do is have a private variable:
>
> private var datagridChangeHandler_func
>
> and then create the delegate:
>
> datagridChangeHandler_func = Delegate.create(this, datagridChangeHandler);
>
> Thany you would add and remove it as:
>
> _dg.addEventListener("change", datagridChangeHandler_func);
>
> _dg.removeEventListener("change", datagridChangeHandler_func);
>
> - James
>


_______________________________________________
[email protected]
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