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..
[as]
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;
}
[/as]
This entry was posted on Monday, October 5th, 2009 at 2:00 pm
You can follow any responses to this entry through the RSS 2.0 feed.

Xing
LinkedIn
Twitter
Delicious
Facebook