Blog
Experiencia y elegancia
Empollandome un post de Matthew Tretter AKA Exanimo acerca de garbage collection y misticismos varios... he encontrado una forma muy elegante de eliminar un event listener que creo sea desconocida a muchos.
A continuacion el codigo..
Actionscript:
-
private var _timer:Timer;
-
-
private function _startTimer():void
-
{
-
this._myTimer = new Timer(1000, 1);
-
-
// AÑADIR EVENT LISTENER...
-
this._myTimer.addEventListener(TimerEvent.TIMER, this._timerHandler);
-
-
-
-
this._myTimer.start();
-
}
-
-
private function _timerHandler(e:TimerEvent):void
-
{
-
// ELIMINAR EVENT LISTENER CON ARGUMENTS CALLEE
-
e.currentTarget.removeEventListener(e.type, arguments.callee);
-
-
// We're done with the timer. Let it die.
-
this._myTimer = null;
-
}

Xing
LinkedIn
Delicious
Flickr