Ktu wrote:
When the code below is run, the eventListener still fires. I was under the
impression that it would not because the eventListener uses a weak
reference, and thus get garbage collected.

var sp:Sprite = new Sprite ();
sp.addEventListener (Event.ENTER_FRAME, function (e:Event):void {
     trace(getTimer());
}, false, 0, true);
sp = null;

Am I just wrong?

Yes and No. Yes, in that you assume that just removing all references will stop the listener right there and then. No, in that it will be eligible for garbage collection.

But there is no guarantee when the garbage collection is performed, and until it has been performed, the listener will keep on working.

If you need things to stop doing things _now_, turn them off yourself.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to