如何在 Flash CS4 中管理带有链接类的库符号以在 Flash Builder 4 中编译/调试? [英] How do I manage library symbols with linked classes in Flash CS4 to compile/debug in Flash Builder 4?

查看:21
本文介绍了如何在 Flash CS4 中管理带有链接类的库符号以在 Flash Builder 4 中编译/调试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Flash CS4(以下简称Flash")构建视频播放器,以创建图形符号并使用 Flash Builder 4(FB4")进行编译和调试.以下是我在当前工作流程中采取的步骤:

I'm building a video player using Flash CS4 (hereby referred to as "Flash") to create the graphic symbols and compiling and debugging with Flash Builder 4 ("FB4"). Here are the steps I take in my current workflow:

--在 Flash 中创建图形符号.我为播放器创建了几个不同的符号,但在这里我只关注播放/暂停按钮(ppbutton").

--Create the graphic symbols in Flash. I've created a few different symbols for the player, but I'll focus on just the play/pause button ("ppbutton") here.

--在库"面板中,我转到 ppbutton 元件的链接属性并链接到扩展 MovieClip 的名为 assets.PlayPauseButtonAsset 的类.我实际上没有资产包,也没有 PlayPauseButtonAsset 的类文件,因为 Flash 会在我发布时为我创建它们.

--In the Library panel, I go to the ppbutton symbol's Linkage properties and link to a class named assets.PlayPauseButtonAsset that extends MovieClip. I do not actually have an assets package nor do I have a class file for PlayPauseButtonAsset as Flash will create them for me when I publish.

--在 Flash 的发布设置中,我将项目设置为导出将在 FB4 中使用的 SWC,名为 VideoPlayerAssets.swc.

--In Flash's Publish settings, I set the project to export a SWC that will be used in FB4, called VideoPlayerAssets.swc.

--创建 SWC 后,我创建名为VideoPlayer"的 FB4 项目并将 SWC 添加到我的路径中.FB4 自动在默认包中创建类 VideoPlayer.

--After the SWC is created, I create my FB4 project called "VideoPlayer" and add the SWC to my path. FB4 creates the class VideoPlayer in the default package automatically.

--在 VideoPlayer.as 中,我导入了 assets.*,它导入了我在 Flash 中创建的所有符号类,可通过 VideoPlayerAssets.swc 获得.我现在可以实例化 ppbutton 并添加到舞台,如下所示:

--In VideoPlayer.as, I import assets.*, which imports all of the symbol classes I created in Flash and are available via VideoPlayerAssets.swc. I can now instantiate the ppbutton and add to the stage, like this:

var ppbutton:PlayPauseButtonAsset = new PlayPauseButtonAsset();
addChild(ppbutton);

此时 ppbutton 没有任何功能,因为我没有为它创建任何代码.所以我创建了一个名为 video.controls.PlayPauseButtonLogic 的新类,它扩展了 assets.PlayPauseButtonAsset.我添加了一些逻辑,现在我可以使用这个新类在舞台上放置一个可用的 ppbutton:

At this point ppbutton doesn't have any functionality because I didn't create any code for it. So I create a new class called video.controls.PlayPauseButtonLogic which extends assets.PlayPauseButtonAsset. I add some logic, and now I can use that new class to put a working ppbutton on the stage:

var ppbutton:PlayPauseButtonLogic = new PlayPauseButtonLogic();
addChild(ppbutton);

这很好用,但您可能会问为什么我不首先将 Flash 中的 ppbutton 符号链接到 video.controls.PlayPauseButtonLogic 类.原因是我有一个设计师在 Flash 中创建 UI,我不想每次更改逻辑时都必须从 Flash 重新发布 SWC.基本上,我希望我的设计师能够在 Flash 中制作一个符号,将该符号链接到 Linkage 属性中一个逻辑命名的类,然后导出 SWC.除非设计人员对符号或布局进行更改,否则我不想再次触及该 .fla 文件.我也在为该项目使用版本控制系统,确保只有设计人员接触 .fla 文件会更清晰.

This works fine, but you may be asking why I didn't just link the ppbutton symbol in Flash to the video.controls.PlayPauseButtonLogic class in the first place. The reason is that I have a designer creating the UI in Flash and I don't want to have to re-publish the SWC from Flash every time I make a change in the logic. Basically, I want my designer to be able to make a symbol in Flash, link that symbol to a logically named class in Linkage properties, and export the SWC. I do not want to have to touch that .fla file again unless the designer makes changes to the symbols or layout. I'm using a versioning system for the project as well and it's cleaner to make sure only the designer is touching the .fla file.

所以,最后,这是我遇到的问题:

So, finally, here's the issue I'm running into:

--随着设计变得越来越复杂,设计者正在嵌套符号以在控制栏上定位视频控件.他创建了一个控制栏符号并将其链接到 assets.ControlBarAsset.控制栏符号包含 ppbutton 符号.

--As the design gets more complex, the designer is nesting symbols to position the video controls on the control bar. He creates a controlbar symbol and links it to assets.ControlBarAsset. The controlbar symbol contains the ppbutton symbol.

--设计者发布了 SWC 并且 ControlBarAsset 现在在 FB4 中可用.我创建了一个名为 video.controls.ControlBarLogic 的新类,它扩展了 assets.ControlBarAsset 以便我可以向控制栏添加一些逻辑,并将控制栏添加到舞台:

--The designer publishes the SWC and ControlBarAsset is now available in FB4. I create new class called video.controls.ControlBarLogic that extends assets.ControlBarAsset so I can add some logic to the controlbar, and I add the controlbar to the stage:

var controlbar:ControlBarLogic = new ControlBarLogic();
addChild(controlbar);

--这有效,但 ppbutton 不执行任何操作.那是因为 ppbutton 在 controlbar 内部时,仍然只链接到没有任何逻辑的 PlayPauseButtonAsset.我不再实例化 ppbutton 对象,因为它是控制栏的一部分.

--This works, but the ppbutton doesn't do anything. That's because ppbutton, while inside controlbar, is still only linked to PlayPauseButtonAsset, which doesn't have any logic. I'm no longer instantiating a ppbutton object because it's part of controlbar.

这就是我今天被困的地方.我似乎无法简单地将控制栏的 ppbutton 重新转换为 PlayPauseButtonLogic,因为我收到了类型错误.而且我不想创建一个必须实例化每个视频播放器控件的类,根据设计师放置它们的方式将它们放置在舞台上的 x 和 y 值处,因为这需要我打开.fla 并检查符号的各种属性,然后将这些值添加到代码中.如果设计者进行了更改,我每次都必须进入代码,以便每次更新这些属性.不好.

That's where I'm stuck today. I can't seem to simply re-cast controlbar's ppbutton as PlayPauseButtonLogic as I get a Type error. And I don't want to have to make a class that has to instantiate each of the video player controls, the place them at their x and y values on the stage according to how the designer placed them, as that would require me to open the .fla and check the various properties of a symbol, then add those values to the code. If the designer made a change, I'd have to go into the code each time just to update those properties each time. Not good.

如何重新转换嵌套符号以使用我创建的扩展资产类的逻辑类?请记住,解决方案不是将 Flash 符号链接到实际的类,因此我不必一直重新编译 SWC,除非有一种无需重新编译 SWC 的方法.我希望设计师做他的事情,发布 SWC,然后完成它.然后我可以获取他的 SWC,将我的逻辑应用于他的资产,并能够调试和编译最终的 SWF.

How do I re-cast nested symbols to use the logic classes that I create that extend the asset classes? Remember, the solution is not to link Flash symbols to actual classes so I don't have to keep recompiling the SWC, unless there's a way to do that without having to re-compile the SWC. I want the designer to do his thing, publish the SWC, and be done with it. Then I can take his SWC, apply my logic to his assets, and be able to debug and compile the final SWF.

推荐答案

以下是我有时使用的解决方案:

Here is the solution that i use sometimes:

不要让 PlayPauseButtonLogic 扩展 PlayPauseButtonAsset,使用这个类作为 PalyPauseButtonAsset 的变形器,使用组合而不是继承!;).

Instead of making PlayPauseButtonLogic extends PlayPauseButtonAsset, use this class as a warpper of PalyPauseButtonAsset, use composition instead of inheritance ! ; ).

您将在 ControlBarLogic 类中得到类似的信息:

You will get something like this in your ControlBarLogic class:

//constructor exemple
public function ControlBarLogic(){
     //all logic of PPButton is inside PlayPauseButtonLogic
     //you just pass a reference to the PlayPauseButtonAsset button contained inside ControlBarAsset
     var ppButtonLogic: PlayPauseButtonLogic=new PlayPauseButtonLogic(refToButtonAsset)
     //the warper class can extends EventDispatcher so you will be able to listen to custom or redisatched events
     ppButtonLogic.addEventListener("ppPause",onPause)
}

希望能帮到你

这篇关于如何在 Flash CS4 中管理带有链接类的库符号以在 Flash Builder 4 中编译/调试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆