使用 SWC 资产时需要额外的包装器或装饰器类吗?

发布于 2024-08-03 23:33:33 字数 405 浏览 6 评论 0原文

我仍在学习如何使用 Flex SDK 进行编译。我正在学习如何使用 SWC 文件和 [EMBED] 语句将我的资产提取到我的应用程序中。

使用 Flash IDE,我可以将库资源链接到类,并且它会自动嵌入到我的自定义类中。所以这是 1 类中的 1 项资产。使用 Flex SDK 和 SWC 文件,我似乎只能*在变量级别提取资源,因此我最终得到了包含另一个类的自定义类 - 这意味着我有一个额外的包装器/decorator(无论你想怎么称呼它)类,我在使用 Flash IDE 时没有。

这是人们通常做的事情吗?这不显得多余吗?

  • 我读过 Colin Moock 的“Essential Actionscript 3.0”,其中他提到了有关在类级别将 SWF 作为二进制数据嵌入的内容...WTF。

I'm still learning how to compile with the Flex SDK. And I'm learning how to use SWC files and [EMBED] statements to pull my assets into my application.

With the Flash IDE, I can link a library asset to a class and it's automatically embedded into my custom class. So that's 1 asset in 1 class. With the Flex SDK and SWC files, it seems I can only* pull in assets at the variable level, so I end up with my custom classes containing yet another class -- this means I have an extra wrapper/decorator (whatever you want to call it) class that I didn't have when using the Flash IDE.

Is this what people typically do? Doesn't that seem superfluous?

  • I've read Colin Moock's 'Essential Actionscript 3.0', where he mentions something about embedding a SWF at class-level as binary data... WTF.

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

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

发布评论

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

评论(2

佼人 2024-08-10 23:33:33

要将符号直接关联到类,请执行以下操作。这也适用于所有类型的子类(只要它们扩展了适当的基类):

package foo {

    import flash.display.Sprite;    

    [Embed(source='../../../../../../assets/Assets.swf', symbol='InfoPopup')]
    public class InfoPopup extends Sprite {

        public function InfoPopup(){
            trace("constructor!");
        }

    }

}

To associate a symbol directly to a class do like this. This works for all kinds of subclasses aswell (as long as they extend the appropriate base class):

package foo {

    import flash.display.Sprite;    

    [Embed(source='../../../../../../assets/Assets.swf', symbol='InfoPopup')]
    public class InfoPopup extends Sprite {

        public function InfoPopup(){
            trace("constructor!");
        }

    }

}
再浓的妆也掩不了殇 2024-08-10 23:33:33

与 Flash 库资源关联的类必须包含在同一 SWC 中。

那么,当Flash编译SWC时,它会找到关联的类并将它们绑定在一起吗?

如果是这样的话,那么艺术作品和代码会在同一个 SWC 文件中耦合在一起吗?我认为 Flex w/ SWC 很棒,因为艺术作品解耦...?

编辑:这不起作用。我实例化 SWC 资产的唯一方法是它继承自基类,所以看来我无法将自定义类与 SWC 资产关联起来??????!!!!!!< /em>

A class associated with a Flash library asset must be contained within the same SWC.

?

Then, when the SWC is compiled by Flash, it finds the associated class and binds them together?

If this is the case, then artwork and code is coupled together in the same SWC file? I thought Flex w/ SWCs was great because artwork was decoupled...?

EDIT: This is not working. The only way I can instantiate a SWC asset is if it inherits from the base class, so it seems I can't associate custom classes with SWC assets?????!!!!!!

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