Good day!
I noticed that in anonymous event handler this
is referenced to global
, not my class. I know that I can use outer referenced variables (because it creates closures), but how to get right this
context?
Simple example:
_movieClipClassVariable = new MyCustomSpriteSubclass();
_movieClipClassVariable.addEventListener(MouseEvent.CLICK, function(event:Event):void {
trace(this); //gives 'global'
});
What about memory usage and garbage collection objects with anonymous handlers? Is declaring handlers as class method better?