You can use arguments.callee to let a anonymous listener remove itself.

Cheers
Ralf.



On Fri, Dec 12, 2008 at 7:23 PM, Alex Harui <aha...@adobe.com> wrote:
> I think Amy's point is that, w/o a reference to the anonfun, you can't call
> removeEventListener on it.  If I do:
>
>
>
> someObj.addEventListener("foo", function (e:Event) { … } );
>
>
>
> someObj will release the anonfun when it gets garbage collected.  However,
> until that time, all objects in the scope chain won't be collectable.  I
> don't know if that's the case in Java.
>
>
>
> From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On
> Behalf Of Mark Carter
> Sent: Friday, December 12, 2008 6:28 AM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] Best practice for calling asynchronous functions?
>
>
>
> So are you saying that, in general, anonymous functions should not be used
> as
> listeners?
>
> If its anything like in Java, (once the calling method returned) the
> anonymous function would only be referenced by the event dispatcher and so
> (assuming weak references are not used) would only be garbage collected when
> the event dispatcher is garbage collected. At least, that's how I understand
> it.
>
> I posted a question about this a few weeks ago, but didn't get a reply.
>
> Amy-28 wrote:
>>
>> My understanding is that anonymous functions _cannot_ get garbage
>> collected unless you use weak references when you add them. Which
>> means there's a really good chance they'll get garbage collected
>> before they get called.
>>
>
> --
> View this message in context:
> http://www.nabble.com/Best-practice-for-calling-asynchronous-functions--tp20930596p20976648.html
> Sent from the FlexCoders mailing list archive at Nabble.com.
>
> 

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

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Alternative FAQ location: 
https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:flexcoders-dig...@yahoogroups.com 
    mailto:flexcoders-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
    flexcoders-unsubscr...@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/

Reply via email to