0

Is it possible to dispatch an event from an object when an event listener is added to that same object, without overriding the addEventListener method of that class?

I am working on a modularized application in AS3. Several of the modules register events on a component in the main application mxml file. I would like to fire an event anytime an event is registered to the component from any module, without putting "dispatchEvent(someEvent)" after every addEventListener.

Any input would be greatly appreciated?

user163757
  • 6,795
  • 9
  • 32
  • 47

1 Answers1

1

I don't know of any built-in that will help you, but you could just write your own function to encapsulate those.

public static function addEvent(ed:IEventDispatcher, evt:String, handler:Function) {
  ed.addEventListener(evt, handler, false, 0, true);
  ed.dispatchEvent(new Event("addedEvent"));
}
Glenn
  • 5,334
  • 4
  • 28
  • 31