Actionscript 项目编译为 swf。我怎样才能用flex加载它并使用它提供的功能?

发布于 2024-08-15 06:42:31 字数 581 浏览 1 评论 0原文

我有一个 ActionScript 项目,其中包含几个使用 Adob​​e Flex 编译为 swf 的类(通过创建一个 ActionScript 项目并单击“导出 -> 发布构建”)

有没有办法加载该 swf,以便我能够加载它类并在不同的 swf 上使用它们?

我知道我可以使用以下代码来加载 swf 文件: var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

loader.load(new URLRequest("game.swf"));
addChild(loader);

(摘自将 SWF 加载到 ActionScript 3 项目中 (Flex Builder)) 但我如何实际创建该 swf 中的类的实例?

谢谢!

I have an ActionScript project with several classes that i compiled as an swf using Adobe Flex (by creating an actionscript project and clicking on export -> release build)

Is there a way to load that swf so i'll be able to load it's classes and use them on a different swf ?

i know i can use the following code to load an swf file:
var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);

loader.load(new URLRequest("game.swf"));
addChild(loader);

(from Loading a SWF into an ActionScript 3 project (Flex Builder)) but how can i actually create an instance of the classes i have in that swf ?

thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最美的太阳 2024-08-22 06:42:31

请查看

Have a look at this.

羁拥 2024-08-22 06:42:31

例如,您可以使用函数 getDefinition 来获取对要实例化的类的引用。

这将取决于您的 swf 在什么上下文中加载的方式。

//check if the class exist into applicationDomain
if (applicationDomain.hasDefinition(name)) {
  // get the class reference from applicationDomain
  var clazz:Class=Class(applicationDomain.getDefinition(name));
 // and instanciate
 var myInstance:XXX=(new clazz()) as XXX;
}

You can use the function getDefinition for example to get a reference to the class to istanciate.

It will depend how your swf is loaded in what context.

//check if the class exist into applicationDomain
if (applicationDomain.hasDefinition(name)) {
  // get the class reference from applicationDomain
  var clazz:Class=Class(applicationDomain.getDefinition(name));
 // and instanciate
 var myInstance:XXX=(new clazz()) as XXX;
}
隔纱相望 2024-08-22 06:42:31

请查看以下 URL: Adobe LiveDocs 站点(查看标题为“嵌入 SWF 文件”的部分)。

Take a look at this URL from the Adobe LiveDocs site (Look at the section titled 'Embedding SWF files').

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文