Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-08 Thread W.R. de Boer
Yes, but it can also cause a lot of trouble when used. I have had causes where the event listener got deleted too early and then you spend a lot of time finding the issue. And that was not with the Loader-class and Event.COMPLETE or others. ___

RE: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-08 Thread Merrill, Jason
So what would be wrong with always using strong references and always deleting them when you're done? That's what I do - I feel like I have more control over what's going on in my code that way. Sure, if I forget to remove it, it could still be out there, but if you get in the habit of always

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-08 Thread Piers Cowburn
Yep I'm with you – it definitely makes sense to have it default to false...would lead to a lot of unexpected behaviour especially for beginners if it defaulted to true. Piers On 8 Feb 2010, at 14:41, Merrill, Jason wrote: So what would be wrong with always using strong references and always

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread Henrik Andersson
Steven Sacks wrote: Guess what never fires? If you guessed onComplete, you win the prize. You do realize that this is not guaranteed, right? It might not fire, but it may also do fire. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com

RE: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread Cor
Could you give an example of the way you use the strong listener? TIA -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Steven Sacks Sent: zondag 7 februari 2010 4:32 To: Flash Coders List Subject: Re:

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread wdb
Yes, I am doing the same because the trouble weak event listeners can cause. function loadImage():void { var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, onComplete, false, 0, true); loader.load(new URLRequest(url)); } function

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread Steven Sacks
function onComplete(event:Event):void { event.target.removeEventListener(Event.COMPLETE, onComplete); } Easy peasy. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread Piers Cowburn
I use a strong listener only when I know I'm not holding a reference to the dispatcher anywhere else. In all other cases, i.e. if I know I'm going to be keeping the dispatcher on the display list (if it's a DisplayObject) until I no longer need it, or if I know I'm storing a reference the

RE: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread Cor
Oooh, OK, it is also the way I do it. I didn't understand the difference between strong and weakly. Not my native language, I am Dutch. Thanks for clearing it to me! -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com]

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-07 Thread Christoffer Enedahl
Piers Cowburn skrev: That way, if I forget to remove the event listener in a destroy method or whatever, it should still end up eligible for GC. Cases where the event doesn't fire because a weak reference was used only happen if there are no strong references anywhere else, so the object

Re: [Flashcoders] Re: is it ever ideal to NOT use weak references?

2010-02-06 Thread Steven Sacks
function loadImage():void { var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, onComplete, false, 0, true); loader.load(new URLRequest(url)); } function onComplete(event:Event):void { trace(event); } Guess what never fires? If you guessed onComplete,