You could try my EventManager class:

 

http://lab.zeusdesign.net/?p=1

 

You won't have to use Delegate at all. There's an argument for a specific
function to call for the listener you are adding. It doesn't have all the
same functionality as EventDispatcher yet, so it might not be right for you,
but I've switched to it in my projects without a hitch.

 

Josh Tynjala

Zeus Design

 

------------------------------

Date: Thu, 27 Oct 2005 15:39:17 +0200

From: "Martin Klasson" <[EMAIL PROTECTED]>

Subject: RE: [Flashcoders] removeEventListener not working?

To: "Flashcoders mailing list" <[email protected]>

Message-ID:

      <[EMAIL PROTECTED]>

Content-Type: text/plain;     charset="us-ascii"

 

 

I just read about it on another site.

Seems to be the only solution, to store it in a variable.

-that is a little to bad really, but I guess I have to live with that.

 

Thanks for your answers.

 

 

-----Original Message-----

From: [EMAIL PROTECTED]

[mailto:[EMAIL PROTECTED] On Behalf Of Helen

Triolo

Sent: den 27 oktober 2005 15:20

To: Flashcoders mailing list

Subject: Re: [Flashcoders] removeEventListener not working?

 

You have to store a reference to the delegate to be able to remove it.  

A modification of a post by Till S:

 

function clearListeners():Void {

   fntController.removeEventListener('onFinished', fdelegate);

}

var fdelegate = Delegate.create(this, fontsLoaded);

fntController.addEventListener('onFinished', fdelegate);

 

cleanListeners();

 

Helen

 

 

Martin Klasson wrote:

 

>I pasted in wrong line at the bottom, should be like this:

> 

>// ADD

>fntController.addEventListener('onFinished', Delegate.create(this,

>fontsLoaded));

> 

>// REMOVE DOESN'T WORK

>fntController.removeEventListener('onFinished', Delegate.create(this,

>fontsLoaded));

> 

> 

>The problem is that I have used the Delegate in the addEventListener.

> 

>If I skip the Delegate on both the add and remove, then it works.

>-but then I will have the wrong scope as well in the functions that

gets

>called ;(

> 

>So how do I remove a eventlistener when it has been added with a

>delegate?

> 

>/ martin

>  

> 

 

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to