Flash、ActionScript:从外部 SWF 加载资源

发布于 2024-08-03 00:07:32 字数 200 浏览 3 评论 0原文

我们有一个小部件 (SWF),需要将其分解为两个 SWF。主 SWF 将包含所有编程和业务逻辑,并且还将加载第二个 SWF 文件,其中包含资源、字体等。

我在 Flash 方面的经验有限,但我知道这可以在 Flex 中完成。无论如何,我们必须在 Flash CS3 中进行。在 Flash 中可以做到这一点吗?如果是,我们需要遵循哪些步骤?

谢谢, 斯里

We have a widget (SWF) that needs to be broken into two SWFs. The main SWF will contain all the programming and business logic and it will also load a second SWF file which will contain the assets, fonts etc.

I have limited experience in Flash but I know it can be done in Flex. Anyway here we have to do it in Flash CS3. Will it be possible to do this in Flash? If yes, what are the steps we need to follow?

Thanks,
Sri

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

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

发布评论

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

评论(2

神经暖 2024-08-10 00:07:32

从外部 SWF 加载资源时,实例化存储在外部 SWF 中的类通常很有用 - 例如,通常以这种方式访问​​字体。

执行此操作时,您必须确保本地 SWF 具有这些类的定义,并且仅将两个 SWF 文件一起编译并不能保证这一点。更具体地说,如果一个 SWF 依赖于另一个 SWF 文件中的类,那么两个 SWF 文件最终都会携带类定义的副本,并且当您在运行时加载外部 SWF 文件时,您会遇到转换错误,因为虚拟机不知道相同的内容外部 SWF 中的命名类与您拥有的完全相同。

为了解决该问题,您需要在加载的 SWF 上使用 ApplicationDomain.getDefinition() - 请参阅此处的 详细示例。除了有关如何使用 Loader 的详细示例之外,它们还展示了如何从外部 SWF 获取 Class 对象。

When loading assets from an external SWF it is often useful to instantiate classes stored in the external SWF - for example Fonts are often accessed that way.

When doing such, you have to make sure that your local SWF has the definition of these classes, and simply compiling both SWF files together does not guarantee that. More specifically, if on SWF is dependent on classes in another, then both SWF files end up carrying copies of the class definitions and when you load the external SWF file in the runtime you get casting errors because the VM doesn't know that the same named class in an external SWF is the exact same as the one you have.

In order to work around the problem you need to use ApplicationDomain.getDefinition() on the loaded SWF - see here for a detailed example. In addition to a detailed example on how to use Loader they also show how to get Class objects from an external SWF.

瞎闹 2024-08-10 00:07:32

查看 Loader 类。代码可能比示例中的代码更简单,但它只是一个开始。 flashandmath.com 网站上有一个详细解释的教程。

在你的主fla(带有逻辑)中,创建一个Loader,告诉它加载资源,在Event.INIT上使用资源。

Have a look at the Loader class. Code can be simpler than the one in the Example, but it's a start. There is a well explained tutorial on the flashandmath.com website.

In you main fla ( with logic ), create a Loader, tell it to load the assets, on Event.INIT, use the assets.

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