gpt4 book ai didi

actionscript-3 - 为什么我得到 "undefined method"用于实现的 IEventDispatcher 接口(interface)?

转载 作者:行者123 更新时间:2023-12-04 06:39:32 24 4
gpt4 key购买 nike

我有一个奇怪的情况,我看不到为什么我实现的 IEventDispatcher 接口(interface)没有编译,我得到 Error: Call to a possibly undefined method addEventListenerError: Call to a possibly undefined method removeEventListener.
很有可能我在这里做了一些非常愚蠢的事情,我只是不知道它是什么......

以下是引发这些错误的类中的方法(意味着在 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
{

}

这是事件调度程序类...
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);
}

}

}

最佳答案

瞎猜,你的包名是view而您正试图调用view.addEventListener ,尝试更改包名。虽然本地变量 view应该首先使用。

关于actionscript-3 - 为什么我得到 "undefined method"用于实现的 IEventDispatcher 接口(interface)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13519372/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com