一个不错的简单开始一天!
我无法在dispatchEvent
中使用static class
,我想知道是否有人知道如何实现类似的功能,或者是否有可能从我的静态类中调用dispatchEvent?
我基本上想在静态类中的功能完成时在Flash文件中通知我的 ActionScript 代码。
谢谢,
最佳答案
在阅读了答案并理解了我可以实现的目标之后,我实现了以下内容(如果以后的用户看到一些示例代码,它将对用户有所帮助)。
private static var dispatcher:EventDispatcher = new EventDispatcher();
public static function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void {
dispatcher.addEventListener(type, listener, useCapture, priority, useWeakReference);
}
public static function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void {
dispatcher.removeEventListener(type, listener, useCapture);
}
public static function dispatchEvent(event:Event):Boolean {
return dispatcher.dispatchEvent(event);
}
public static function hasEventListener(type:String):Boolean {
return dispatcher.hasEventListener(type);
}
关于flash - 静态类中的dispatchEvent-AS3,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8756553/