gpt4 book ai didi

flash - 静态类中的dispatchEvent-AS3

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

一个不错的简单开始一天!

我无法在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/

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