Removing the Event listener...

2005-02-25 Thread anumathew76

Hi,
I want to remove an event associated to a component. I have a button

mx:Button id=btn label=RemEvent click=remEvent() / I want to 
remove the click event handler for the button
I tried btn.removeEventListener(click,remEvent). It doesn't seem 
to be working.Please advise me.
Thanks,
Anu







RE: [flexcoders] Removing the Event listener...

2005-02-25 Thread Matt Chotin








Hmm, I think its probably harder to
do this straight from the tag. You may need to set this up differently.



mx:Script

 var funcToRemove : Function;



 function addListener()

 {

 funcToRemove = mx.utils.Delegate(this,
remEvent);

 btn.addEventListener(click,
funcToRemove);

 }



 Function remEvent()

 {

 Btn.removeEventListener(click,
funcToRemove);

 }

/mx:Script



mx:Button id=btn
initialize=addListener() /



No idea if this works, but should giveyou
the idea. If the Delegates dont work you may need to use a listener
object instead of passing in a straight function. I think we discuss listener
objects in the docs.



Matt











From: anumathew76
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 24,2005
10:21 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Removing the
Event listener...






Hi,
I want to remove an event associated to a
component. I have a button

mx:Button id=btn
label=RemEvent click=remEvent() / I want to
remove the click event handler for the button
I tried
btn.removeEventListener(click,remEvent). It doesn't seem 
to be working.Please advise me.
Thanks,
Anu













RE: [flexcoders] Removing the Event listener...

2005-02-25 Thread Matt Chotin








Yes, the cell renderers will be zombied,
sort of. Its not actually truly zombied because we recycle thecell
renderers. When a row isnt needed due to resizing or whatever it goes
on a free list, when its needed well bring it back. What I dont
remember off-hand is if we do decide to clear the free list if we go through
and actually remove the MovieClip. I think it becomes moot if we do that since
the Player will destroy the object. Though there will be dangling references
to undefined I think, but at least you wont have lots of code executing
that you dont want.



Matt











From: Dirk Eismann
[mailto:[EMAIL PROTECTED] 
Sent: Friday, February 25, 2005
12:37 AM
To: [EMAIL PROTECTED]
Subject: RE: [flexcoders] Removing
the Event listener...







Btw, I always wondered if references to listeners will get
removed automatically. 











For example, a List control myListis using a custom
cellrenderer. The cellrendererinstanceregisters itself with another
componentby doing











 listOwner.addEventlistener(change, this)











now if there were 10 visible rows in the List then there
would be 10 listeners (references) added to myList. What happens if I do
myList.removeAll()? Will there be zombie references to the cell
renderer instances because they are still stored inside the array of listeners
for the List control?











Thanks,





Dirk.

















-Original
Message-
From: Matt Chotin [mailto:[EMAIL PROTECTED]
Sent: Friday, February 25, 2005
7:39 AM
To: [EMAIL PROTECTED]
Subject: RE: [flexcoders] Removing
the Event listener...





Hmm, I think its probably harder to
do this straight from the tag. You may need to set this up differently.



mx:Script

 var funcToRemove : Function;



 function addListener()

 {

 funcToRemove =
mx.utils.Delegate(this, remEvent);


btn.addEventListener(click, funcToRemove);

 }



 Function remEvent()

 {


Btn.removeEventListener(click, funcToRemove);

 }

/mx:Script



mx:Button id=btn
initialize=addListener() /



No idea if this works, but should giveyou
the idea. If the Delegates dont work you may need to use a
listener object instead of passing in a straight function. I think we
discuss listener objects in the docs.



Matt











From: anumathew76
[mailto:[EMAIL PROTECTED] 
Sent: Thursday, February 24,2005
10:21 PM
To: [EMAIL PROTECTED]
Subject: [flexcoders] Removing the
Event listener...






Hi,
I want to remove an event associated to a
component. I have a button

mx:Button id=btn
label=RemEvent click=remEvent() / I want to
remove the click event handler for the button
I tried
btn.removeEventListener(click,remEvent). It doesn't seem 
to be working.Please advise me.
Thanks,
Anu




















RE: [flexcoders] Removing the Event listener...

2005-02-25 Thread Dirk Eismann



Wouldn't itbe a good enhancement to the EventDispatcher mix-in then 
to wipe references to undefined automatically when the removeEventListener() 
method is invoked?

Dirk.

-Original Message-From: Matt Chotin 
[mailto:[EMAIL PROTECTED]Sent: Friday, February 25, 2005 
10:34 AMTo: flexcoders@yahoogroups.comSubject: RE: 
[flexcoders] Removing the Event listener...

Yes, the cell 
renderers will be zombied, sort of. Its not actually truly zombied 
because we recycle the cell renderers. When a row isnt needed due to 
resizing or whatever it goes on a free list, when its needed well bring it 
back. What I dont remember off-hand is if we do decide to clear the 
free list if we go through and actually remove the MovieClip. I think it 
becomes moot if we do that since the Player will destroy the object. 
Though there will be dangling references to undefined I think, but at least 
you wont have lots of code executing that you dont 
want.

Matt





From: Dirk 
Eismann [mailto:[EMAIL PROTECTED] Sent: Friday, February 25, 2005 12:37 
AMTo: 
flexcoders@yahoogroups.comSubject: RE: [flexcoders] Removingthe 
Event listener...


Btw, I always wondered if 
references to listeners will get removed automatically. 




For example, a List control 
myListis using a custom cellrenderer. The 
cellrendererinstanceregisters itself with another componentby 
doing



 
listOwner.addEventlistener("change", this)



now if there were 10 visible rows 
in the List then there would be 10 listeners (references) added to myList. 
What happens if I do myList.removeAll()? Will there be "zombie" references to 
the cell renderer instances because they are still stored inside the array of 
listeners for the List control?



Thanks,

Dirk.





-Original 
Message-From: Matt 
Chotin [mailto:[EMAIL PROTECTED]Sent: Friday, February 25, 2005 7:39 
AMTo: 
flexcoders@yahoogroups.comSubject: RE: [flexcoders] Removingthe 
Event listener...

Hmm, I thinkits 
probably harder to do this straight from the tag. You may need toset 
this up differently.

mx:Script
 var 
funcToRemove : Function;

 function 
addListener()
 
{
 
funcToRemove = mx.utils.Delegate(this, 
remEvent);
 
btn.addEventListener(click, funcToRemove);
 
}

 Function 
remEvent()
 
{
 
Btn.removeEventListener(click, funcToRemove);
 
}
/mx:Script

mx:Button 
id=btn initialize=addListener() /

No idea if this 
works, but should give you the idea. If the Delegates dontwork you 
may need to use a listener object instead of passing in a straight 
function. I think we discuss listener objects in the 
docs.

Matt





From: 
anumathew76 [mailto:[EMAIL PROTECTED] Sent: Thursday, February 24, 2005 10:21 
PMTo: 
flexcoders@yahoogroups.comSubject: [flexcoders] Removing the 
Event listener...

Hi,I want to 
remove an event associated to a component. I have a 
buttonmx:Button 
id="btn" label="RemEvent" click="remEvent()" / I want to 
remove the click event handler 
for the buttonI tried 
btn.removeEventListener("click",remEvent). It doesn't seem 
to be working.Please advise 
me.Thanks,Anu