0 Replies Latest reply on May 22, 2015 5:58 AM by 4xyfenix

    EventDispatcher interface

    4xyfenix Level 1

      Hi folks, 

      Firsty I would like to say thank you for providing the stuff. I'am using Flex for a several years and every time I encouter EventDispatcher object I fill sad due to this.

      As for me I would extend the inteface of this entity. At present we have

      addEventListener(eventType, Listener) removeEventListener(eventType, Listener) 

      Every parameter is mandatory. But why don't we have those?

      removeAllEventListeners() removeEventListener(eventType, Listener = null) 

      The last one removes all the listeners of the given type. May be you will consider the extension of EventDispatcher by adding those methods to IEventDispatcher? (even stay compatible with the existing code)

      Current interface excludes the right usage (I mean clean up listeners) of the case where actual listeners decorated by some proxy listener function e.g.

        private function proxy(listener: Function): Function

        {

          function onEvent(event: Event): void

          {

            if (_ignoredEvents.indexOf(event.type) == -1)

            {

              _events.push(event);

            }

       

            if (listener != null) { listener(event); }

          }

       

          return onEvent;

        }

      What would you say?