Here's the test class:
I store a bound method in a week Dictionary, and added to as a listener also
week. The wired thing is that, it will be cleared by Dictionary, but not
event listener... I can't explain this strange behavor, hope someone can
helps.
public class Nothing extends Sprite{
private var sp:Sprite;
private var dic:Dictionary;
public function Nothing(){
super();
sp = new Sprite();
sp.graphics.beginFill(0xFF0000);
sp.graphics.drawCircle(100, 100, 100);
sp.graphics.endFill();
addChild(sp);
var f1:Function = __done;
dic = new Dictionary(true);
dic[f1] = "__done";
sp.addEventListener(MouseEvent.MOUSE_DOWN, __traceDic);
sp.addEventListener(MouseEvent.MOUSE_DOWN, f1, false, 0, true);
}
private function __done(e:Event):void{
trace("__done invoked!");
}
private function __traceDic(e:*):void{
trace("---what is in dic---");
for each(var i:* in dic){
trace(i);
}
trace("---------");
System.gc();
}
}
___________
Click the red area, the out put is :
---what is in dic---
---------
__done invoked!
--
iiley
AsWing http://www.aswing.org
Personal http://www.iiley.com