Hi guys,
Sorry if you feel this is off-topic, but this test is really interesting, i
can't find another better list to discuss this. Here should be some guru can
know the right theory.
See the test code below, you guess/think how many times
"*trace(h.name)"*will be invoked? How long the
* h.handler* will be alive? Notice, twe addEventListener call i used
"useWeakReference=*true*".
Try to run this test, is your gussing right? Why you are wrong/right? (*My
guess is wrong and i don't know why :<*)
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.net.LocalConnection;
import flash.utils.*;
public class TestDic extends Sprite{
public function TestDic(){
var timer:Timer = new Timer(500, 10);
timer.addEventListener(TimerEvent.TIMER, function(e:*):void{
trace(h.name);
}, false, 0, true);
timer.start();
var h:Handler = new Handler();
h.name = "Test handler : ";
stage.addEventListener(MouseEvent.CLICK, h.handler, false, 0, true);
}
}
}
class Handler{
public var name:String;
public function handler(e:*):void{
trace(e);
}
}
--
iiley
AsWing http://www.aswing.org
Personal http://www.iiley.com
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org