title: AS3 - Event listener that only fires once
body: <p>I'm looking for a way to add an EventListener which will automatically removes itself after the first time it fires, but I can't figure a way of doing this the way I want to.</p>
  
  <p>I found this function (<a href="http://code.google.com/p/asphalt2/source/browse/trunk/asphalt2/src/asphalt2/util/EventUtil.as?r=457" rel="noreferrer">here</a>) :</p>
  
  <pre><code>public class EventUtil
  {
      public static function addOnceEventListener(dispatcher:IEventDispatcher,eventType:String,listener:Function):void
      {
           var f:Function = function(e:Event):void
           {
                dispatcher.removeEventListener(eventType,f);
                listener(e);
            }
            dispatcher.addEventListener(eventType,f);
      }
  }
  </code></pre>
  
  <p><br>But instead of having to write :</p>
  
  <pre><code>EventUtil.addOnceEventListener( dispatcher, eventType, listener );
  </code></pre>
  
  <p>I would like to use it the usual way :</p>
  
  <pre><code>dispatcher.addOnceEventListener( eventType, listener );
  </code></pre>
  
  <p><br>Has anybody got an idea of how this could be done?<br>
  Any help would be greatly apprecitated.
  <br><br><hr>
  <em>(I know that Robert Penner's <a href="http://github.com/robertpenner/as3-signals" rel="noreferrer">Signals</a> can do this, but I can't use them since it would mean a lot of code rewriting that I can't afford for my current project)</em></p>