I have some doubt about weak references at eventListener.

When I add a eventListener with  weak reference true, the object don't
get a "point/reference" to it but what happens with eventListener array after
removing this object. This array don't has the reference for garbage collect,
so the garbage collect could collect it, but this object was never removed
from this eventListner array, wasn't it? That's my question. Is this object
removed from eventlistener array when weak reference is true?
Is it feasible to implement it in pure action script or It is a voodoo feature
for compiler?


On Wed, Jan 7, 2009 at 8:27 AM, Manish Jethani <[email protected]> wrote:
> On Wed, Jan 7, 2009 at 4:48 AM, markgoldin_2000
> <[email protected]> wrote:
>> Ok, here what I am getting.
>> I have a container that I am adding different forms to at the run
>> time. These forms are all based on the same class though.
>> So, before I add a new form I am removing current form using:
>> container.removeAllChildren();
>> each form when created is adding a custom event listener to a parent -
>> the container. When a custom event is triggered every form that was
>> created (regardless that it was removed after) gets this custom event
>> to handle.
>
> When you listen for an event on one of your ancestors, you usually
> want to use a weak reference (the last parameter to addEventListener).
> That's because your parent doesn't know you're listening on it, so
> when you've been removed and "discarded", you'll still be around
> because of the event listener.
>
> Manish
>
> 

Reply via email to