But it does matter. Say I create an object on stage through code.

var result:Boolean = super.handleAdd(event);
                        
                        var child:UIComponent = event.relatedObject as 
UIComponent;

                        child.addEventListener(MouseEvent.CLICK, 
handleChildClick,
                                false, 0, true);

then later I delete all the child objects there will be a reference
from the addEventListener floating around so child won't be removed
from memory. 

When you say a to b what do you mean?



--- In flexcoders@yahoogroups.com, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> No one call can remove all listeners.  No one call can remove all
> references, just one at a time.
>  
> If you add a listener on yourself, there is no need to remove it.  It
> might slightly help if it is a DRC object, but eventually it will be
> garbage collected.
>  
> a.addEventListener("foo", b.someMethod) creates a reference from a to b,
> not the other way around.
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of flexaustin
> Sent: Thursday, August 07, 2008 10:27 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Garbage Collection and event listeners
> 
> 
> 
> Is possible to remove all event listeners by doing something like the
> following?
> 
> mc.removeEventListener(*,*,false);
> 
> Though not sure how you would get the count of eventlisteners or
> iterate through them?
> 
> And as far as deleteing any reference to an object can you override
> removechildren and add
> for(var i:int=0; i<this.numChildren-1; i++) 
> { var chld:DisplayObject = this.getChildAt(i); 
> chld.deleteReferenceOnParentDocument(this.parent);
> }
> 
> Or is there a best practice when for when you write code like this:
> addEventListener(ChildEvent.CHILD_ADDED,
> handleAdd);
> 
> To override the removeChilden function to remove the event listener
> above?
> 
> Thanks in advance.
> 
> --JDog
>


Reply via email to