如何将链接的 SWC MovieClip 资源与 FlexBuilder Actionscript 项目中的类关联

发布于 2024-07-26 10:01:55 字数 375 浏览 2 评论 0原文

我越来越多地使用 Flex Builder,并尝试在 Flex Builder 中创建一个相当重资产的应用程序。 我知道如何将 Flash 资源发布或导出为 SWC,以便它们可以在 Flex Builder 中使用,但是如果您有一个在 Flash 中具有帧状态的按钮 MovieClip,该按钮可以导出或包含在作为 SWC 发布的 swf 中,然后您想要将 Flexbuilder 中创建的类文件与此 SWC 资产关联起来吗?

我想避免不必要的往返...每次我需要对 Flash 创作的 MovieClip 类进行编辑时,我都需要编辑该类并重新发布或重新导出到 SWC,以便它可以在 Flex Builder 中使用。 即我想在 Flexbuilder 中完成所有编码,同时在 Flash 中创作图形资源。

I'm using Flex Builder more and more and attempting to create a fairly asset heavy application all in Flex Builder.
I know how to publish or export Flash assets as SWC's so they are available in Flex Builder, but what if you have a button MovieClip with frame states in Flash, which is either exported or included in the swf published as a SWC, and you then want to associate a Class file created in Flexbuilder with this SWC asset?

I want to avoid unnecessary roundtripping...every time I need to make an edit to a Flash authored MovieClip class I would need to edit the Class and re -publish or reexport to a SWC so it is available in Flex Builder. ie I want to do ALL my coding in Flexbuilder while authoring graphical assets in Flash.

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

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

发布评论

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

评论(3

澉约 2024-08-02 10:01:56

我自己一直在尝试为此想出一个好的解决方案。 我发现的最佳解决方案是使用装饰器模式,即使用一个类来装饰另一个类。
假设我想从 Flash 加载一个按钮并将翻转行为封装在按钮中,它可能看起来像这样:

public class AnimatedButton extends Sprite
{
    private var mc:MovieClip;

    public function AnimatedButton( mc:MovieClip )
    {
        this.mc = mc;

        addChild(mc);

        mc.addEventListener(MouseEvent.CLICK, onClick);
        mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
        mc.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
    }

    protected function onClick ( event:MouseEvent ):void
    {
        mc.gotoAndPlay("clicked");
        dispatchEvent( event) );
    }

    protected function onRollOver ( event:MouseEvent ):void
    {
        mc.gotoAndPlay("over");
        dispatchEvent( event) );
    }

    protected function onRollOut ( event:MouseEvent ):void
    {
        mc.gotoAndPlay("out");
        dispatchEvent( event );
    }
}

然后当我想将翻转状态添加到按钮时,我会像这样装饰它:

private var btn:AnimatedButton = new AnimatedButton( new FlashButton() );

这基本上创建了按钮新装饰的功能。 最酷的是,现在我可以在任何具有“over”、“out”和“clicked”框架的按钮上使用它。

I’ve been trying to come up with a good solution for this myself. The best solution I’ve found is using the decorator pattern, where you use one class to decorate another class.
Let’s say I wanted to load a button from flash and encapsulate the rollover behavior in the button it might look something like this:

public class AnimatedButton extends Sprite
{
    private var mc:MovieClip;

    public function AnimatedButton( mc:MovieClip )
    {
        this.mc = mc;

        addChild(mc);

        mc.addEventListener(MouseEvent.CLICK, onClick);
        mc.addEventListener(MouseEvent.ROLL_OVER, onRollOver);
        mc.addEventListener(MouseEvent.ROLL_OUT, onRollOut);
    }

    protected function onClick ( event:MouseEvent ):void
    {
        mc.gotoAndPlay("clicked");
        dispatchEvent( event) );
    }

    protected function onRollOver ( event:MouseEvent ):void
    {
        mc.gotoAndPlay("over");
        dispatchEvent( event) );
    }

    protected function onRollOut ( event:MouseEvent ):void
    {
        mc.gotoAndPlay("out");
        dispatchEvent( event );
    }
}

then when i want to add the rollover states to a button i would decorate it like so:

private var btn:AnimatedButton = new AnimatedButton( new FlashButton() );

this basically creates the button with the newly adorned functionality. The cool thing is now I can use this on any button that has the "over" "out" and "clicked" frames.

來不及說愛妳 2024-08-02 10:01:56

谢谢布兰登。
我遇到的一个问题是使用多帧的 Flash 资源时,例如带有 _up、_over 和 _down 标签的 MovieClip 按钮以及第一帧上的 stop() 操作。
使用嵌入会删除任何基于帧的动作脚本。
对于这种情况有“最佳”解决方案吗?

Thanks Branden.
One issue I'm having is when using flash assets that are multiframe, say such as MovieClip buttons with _up, _over and_down labels and a stop() action on the first frame.
Using embed removes any frame based actionscript.
Is there a 'best' solution for this scenario?

居里长安 2024-08-02 10:01:55

有两种方法可以看待这个问题。 第一种方法(我经常使用)是将 FLA 包含在 Flex 项目的 lib 文件夹中。 然后,在 FLA 中,我将路径设置为 ../src/(发布设置 -> Flash 选项卡 -> ActionScript 3 按钮),以便 Flash 可以访问与我的 Flex 应用程序的其余部分相同的包。 这意味着 SWC 只是我在 Flex 中已有的类的编译版本(因此我什至不必从技术上将 SWC 添加到 Flex 项目中)。

执行此类操作的另一种方法是在Flash 并只需分配各种资源虚拟类 - Flash 会自动为您创建这些资源的类。 然后将该 SWC 导入您的 Flex 项目。 资产本身显然只是愚蠢的 MovieClips - 但您可以编写自己的类来实例化资产并控制它们。

There are two ways to look at this. The first way (that I use fairly often) is to include the FLAs in my lib folder of my Flex project. Then, in the FLA I set the path to ../src/ (Publish Settings - > Flash Tab -> ActionScript 3 Button) so that Flash can reach the same packages as the rest of my Flex application. This means the SWC is just a compiled version of the classes I already have in Flex (hence I don't even have to add the SWC to the Flex project technically)

They other way of doing something like this is to create the assets inside of Flash and just assign the various assets dummy classes - Flash will create the classes for these assets for you automatically. Then you import that SWC into your Flex project. The assets, by themselves, will obviously just be dumb MovieClips - but you can write your own classes that instantiate the assets and control them.

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