You only need to remove listeners on parents and singletons.
Class SomeComponent
{
Var child:Widget;
override protected function createChildren():void
{
child = new Widget();
AddChild(child);
Child.addEventListener(“someEvent”, eventHandler);
}
Private function eventHandler(event:Event):void
{
}
The call to addEventListener creates a reference from child back to
SomeComponent so it will not prevent child from being garbage collected once
there is a call to removeChild(child);
Therefore, in your mxml, the listener does not need to be removed.
On 1/26/10 12:32 PM, "hworke" <[email protected]> wrote:
Hello devs,
I understand that if an UI component has an added
event listener and even if it is removed from its
parent - the memory held by the component will not
be released. Now the question is if I have a button
declared in mxml like this
<mx:Button id="testBtn" click="handleClick()"/>
In this case do I need to remove the click event
listener like this -
testBtn.removeEventListener(MouseEvent.CLICK,handleClick);
or just removing the button from the parent will
take care of this?
--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui