加载 SWF 时不兼容的类

发布于 2024-08-27 20:24:34 字数 259 浏览 5 评论 0原文

我有两个 ActionScript 3 项目,游戏(.swf)和迷你游戏(.swf)。在运行时,主游戏通过 Loader 加载小游戏。我还有一个事件类的共享库(SWC),两者都包含,其中迷你游戏需要调度,游戏需要监听。

第一:这样可以吗?

第二:如果我编译迷你游戏,然后更改事件类以使它们不兼容,然后编译主游戏,会发生什么。尝试加载小游戏 SWF 时 Flash 会崩溃吗? (我希望如此)

第三:如果我更改事件类,但以保留接口级兼容性的方式,会发生什么?

I have two ActionScript 3 projects, game(.swf) and minigame(.swf). At runtime the main game loads the minigame via Loader. I also have a shared library (SWC) of event classes, included by both, which minigame will need to dispatch and game will need to listen to.

First: Is this possible this way?

Second: What will happen if I compile the minigame, then change the event classes so they're incompatible, then compile the main game. Will Flash crash when trying to load the minigame SWF? (I hope so)

Third: And what will happen if I change the event classes, but in a way that preserves interface-level compatibility?

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

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

发布评论

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

评论(1

走野 2024-09-03 20:24:34

如果您有名称相同但不共享相同功能的类,只需为每个类使用不同的类路径(即 com.game.* com.minigame.*),这将避免所有冲突。

基本上,如果多个 SWF 中的类名称相同,则只会使用第一个加载的类。

另一方面,如果您确实想在两个 SWF 之间共享相同的类,请确保仅将它们包含在主 SWF 中(您可以在 Flash IDE 的发布设置或 Flex 的编译器设置中选择包含/排除) SDK)。这将使整个加载过程变得更轻松,并且您将避免与奇怪的冲突相关的错误。

If you have classes named the same but not sharing the same functionality just use a different class path for each (i.e com.game.* com.minigame.*), this will avoid all conflicts.

Basically if a class named the same in several SWFs only the one loaded first will be used.

On the other hand if you really want to share the same classes between both of the SWFs, make sure you only include them in the main SWF (you can choose include/exclude in the publish settings of Flash IDE or in the compiler settings of Flex SDK). This will make the whole loading process a bit lighter and you will avoid weird conflict related bugs.

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