为什么我为已实现的IEventDispatcher接口获取"未定义的方法"?

ant*_*man 4 events actionscript-3

我有一个奇怪的情况,我不明白为什么,我已经实现了IEventDispatcher接口没有编制,我得到Error: Call to a possibly undefined method addEventListenerError: Call to a possibly undefined method removeEventListener.

我很有可能在这里做一些令人难以置信的愚蠢的事情,我只是不知道它是什么......

以下是Class中抛出这些错误的方法(意味着在setTransformListner和"removeTransformListener"主体中处理"view"的方法:

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
{

}
Run Code Online (Sandbox Code Playgroud)

这是Event Dispatcher 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);
        }

        /* INTERFACE flash.events.IEventDispatcher */

        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);
        }

    }

}
Run Code Online (Sandbox Code Playgroud)

Bar*_*klı 5

疯狂的猜测,您的包名是,view并且您尝试调用view.addEventListener,尝试更改包名称.虽然view应该首先使用本地var .