Implement IEventDispatcher

methods to implement :

  • addEventListener
    addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
  • removeEventListener
    removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
  • dispatchEvent
    dispatchEvent(event:Event):Boolean
  • hasEventListener
    hasEventListener(type:String):Boolean
  • willTrigger
    willTrigger(type:String):Boolean

variables to declare :

  • private var eventDispatcher:EventDispatcher;
package classes.events
{
	import flash.events.IEventDispatcher;
	import flash.events.*;
public class CustomObject implements IEventDispatcher { private var eventDispatcher:EventDispatcher;
public function CustomObject() { eventDispatcher = new EventDispatcher(this); trace("new CustomObject"); }
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 removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { eventDispatcher.removeEventListener(type, listener, useCapture); }

public function dispatchEvent(event:Event):Boolean { return eventDispatcher.dispatchEvent(event); }
public function hasEventListener(type:String):Boolean { return eventDispatcher.hasEventListener(type); }
public function willTrigger(type:String):Boolean { return eventDispatcher.willTrigger(type); }
} }