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", you win the prize.

Now imagine that it defaulted to true and you wrote the same thing leaving off the false, 0, true. You would have no idea why it didn't work.

It didn't work because the loader was cleaned up by GC as soon as the loadImage() function reached the end.

Generally, I only use weak listeners with Timers and enter frame listeners. Everything else I use strong listeners and write a remove listener for them when they're expected to unload or be garbage collected at some point.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to