Mar 23

Magic lines of code (Trick-Shot #1)

Tag: Trick ShotsIonut Grosu @ 8:57 pm

Always wanted a magic line of code that will do the job no matter where you put it. : ) For instance this line will remove any eventListener registered on any eventDispatcher target for any type of event.

Considering that “e” is the event:

e.target.removeEventListener(e.type,arguments.callee);

Used something like this … and no matter in which listener you will put it, will do it’s job.

private function onEvent(e:Event):void
{
e.target.removeEventListener( e.type, arguments.callee );
}

It’s not much but you could find it pretty usefull in some cases.

This “trick-shots” category will contain all sort of tiny cool thing like this. So keep an eye on this one.

One Response to “Magic lines of code (Trick-Shot #1)”

  1. AJ says:

    Nice trick!

Leave a Reply