Use strong references when you're adding an event listener to the same
instance dispatching an event.  If it's an anonymous function, you need
to use a strong reference.  Also, use strong references when you want
speed - weak references are slower.

Always use weak references when dealing with singletons (Cairngorm's
event dispatcher is a singleton, hence, always use with Cairngorm), or
objects that live the life of the application.  This includes timers
waiting on call backs also.

 

Not always true but if you have an object you intend to never have
destroyed, but it may also be perfectly safe to use strong references.
Keep in mind though that using a weak reference on, say, an event
listener where a strong one was required may result in things like that
listener not getting called.

 

I'm only new to Flex, but this is as I understand it, and no doubt I've
missed a few things here and there.

 

--Tim Rowe

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Boon Chew
Sent: Tuesday, 15 July 2008 2:08 PM
To: [email protected]
Subject: [flexcoders] When not to use weak references?

 

Hi all,

I have read posts that preached the goodness of weak references for
event listening, but have not read anything that suggests when you
should use strong reference over the weak one, and  the down side to
using weak references.

Any ideas when being weak is not bad thing? :)

- boon

 

 

Reply via email to