0 Replies Latest reply on Nov 19, 2007 1:45 AM by kaeptn-q

    [AS2] Listeners for any Object? UIEventDispatcher -- EventDispatcher:

    kaeptn-q Level 1
      HI - thx for reading.

      Class mx.events.UIEventDispatcher extends mx.events.EventDispatcher -
      and overrides the "dispatchEvent"_Method like this:

      function dispatchEvent(eventObj:Object):Void
      {
      if (eventObj.target == undefined)
      eventObj.target = this;

      this[eventObj.type + "Handler"](eventObj);

      // Dispatch to objects that are registered as listeners for
      // all objects.
      this.dispatchQueue(EventDispatcher, eventObj);

      // Dispatch to objects that are registered as listeners for
      // this object.
      this.dispatchQueue(this, eventObj);
      }

      Comment says (and that is also the difference to EventDispatcher´s implementation of this method) that at first the Event is dispatched to " to objects that are registered as listeners for all objects."

      But it doesn't happen...

      I guess cause we cannot do EventDispatcher.addEventListener, because there is no static function "addEventListener" in the EventDispatcher-class.

      But what is that piece of code good for?

      I'd rather like to be able to add a Listener that listens to an Event indepent of the object that sends the Event (e.g. if you have to add tracking functionallity to a project, you could imaganie to create a kind of "global Listener" to any "click"-Event an track it).

      So, if anybody understands how this coudl work: Help or enlightment will be greatly appreciated!

      Thanks in advance,
      tom