package Events { /* http://www.kirupa.com/forum/showthread.php?223798-ActionScript-3-Tip-of-the-Day/page6 Note that addEventListener only takes functions as listeners, not objects. Also remember that class methods are bound to their instances so when used as listeners, 'this' in the event call still references the orginal class instance no matter what object dispatched the event. By extending the EventDispatcher class or any class that inherits from it like Sprite (all DisplayObjects are inherently EventDispatchers), your class gains access to the EventDispatcher methods. Then, other instances (or the class instance itself) can add methods to instances of that class using addEventListener and in turn they can call those events through dispatchEvent. If there is some reason your class cannot inherit from the EventDispatcher class for example, if its already inheriting from another class which does not inherit from EventDispatcher), then you can use the EventDispatcher constructor to intialize your class instance with the methods of EventDispatcher via aggregation (composition). Just make sure you implement the IEventDispatcher interface (flash.events.IEventDispatcher)*/ import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; import flash.utils.getQualifiedClassName; public class MyDispatcher implements IEventDispatcher { private var eventDispatcher:EventDispatcher; public function MyDispatcher() { trace("new " + getQualifiedClassName(this)); eventDispatcher=new EventDispatcher(this); } public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void { eventDispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); } public function dispatchEvent(event:Event):Boolean { return eventDispatcher.dispatchEvent(event); } public function hasEventListener(type:String):Boolean { return eventDispatcher.hasEventListener(type); } public function removeEventListener(type:String, listener:Function, useCapture:Boolean=false):void { eventDispatcher.removeEventListener(type, listener, useCapture); } public function willTrigger(type:String):Boolean { return eventDispatcher.willTrigger(type); } } } #### package Events { import flash.utils.getQualifiedClassName; public final class MyEventDispatcher extends MyDispatcher { private static var _instance:MyEventDispatcher; public function MyEventDispatcher(dummy:Dummy):void { super(); if (dummy === null) { throw new Error("Call CustomEventDispatcher as CustomEventDispatcher.instance!"); } } public static function get instance():MyEventDispatcher { if (_instance === null) { _instance=new MyEventDispatcher(new Dummy()); trace("new instance " + getQualifiedClassName(_instance)); } trace("get instance " + getQualifiedClassName(_instance)); return _instance; } } } internal class Dummy { }