I have a strange situation where I don’t understand why the IEventDispatcher interface that I implemented does not compile and I get Error: Call to a possibly undefined method addEventListener and Error: Call to a possibly undefined method removeEventListener.
There’s a good chance that I’m doing something incredibly dumb here, I just don’t know what it is ...
Here are the methods in the class that throw these errors (which means the methods that work on the "view" in the body of setTransformListner and "removeTransformListener":
public function setTransformListener(view:AbstractView):void { view.addEventListener(CustomEvent.TRANSFORM, transform); } public function removeTransformListener(view:AbstractView):void { view.removeEventListener(CustomEvent.TRANSFORM, transform); } private function transform(e:CustomEvent):void { }
Here is the event manager class ...
package view { import flash.events.Event; import flash.events.EventDispatcher; import flash.events.IEventDispatcher; public class AbstractView implements IEventDispatcher { private var _dispatcher:EventDispatcher; public function AbstractView():void { _dispatcher = new EventDispatcher(this); } public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void { _dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference); } public function dispatchEvent(evt:Event):Boolean { return _dispatcher.dispatchEvent(evt); } public function hasEventListener(type:String):Boolean { return _dispatcher.hasEventListener(type); } public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void { _dispatcher.removeEventListener(type, listener, useCapture); } public function willTrigger(type:String):Boolean { return _dispatcher.willTrigger(type); } } }
source share