使用带有链接外部类的 SWC 的 ActionScript 3 工作流程

发布于 2024-08-11 00:54:33 字数 1034 浏览 5 评论 0原文

我正在开发一个图形密集型应用程序,该应用程序使用来自一堆不同 FLA 的内容。不过,我是一名编码员,所以我想在 Flash Builder 中完成所有编码,但我希望允许我的设计师仍然使用一些时间线操作,例如 stop();甚至还有一些简单的按钮处理程序来更改视图。我一直在努力寻找适合此类设置的最佳工作流程;我尝试过使用 Embed,但这会剥离时间线代码,我尝试过 Loader,但这并没有给我任何代码完成或编译时检查,而且我目前正在使用 SWC 以及自定义类来子类化内部元素SWC,这似乎是迄今为止最好的组合 - 您可以完成代码,并且时间线脚本仍然可以工作。我遇到的问题是我在 Flash 中有一个相当复杂的视图,我想将真实的类分配给库中的一些其他资源,但它们在 SWC 中导出时不会维护其类关联。

例如,假设我有一个 FLA,其库中的符号名为 View。我给它一个“com.company.view.design.ViewDesign”的链接类。该视图内有 3 个框架,每个框架上都有不同的符号,称为“content1”、“content2”和“content3”。我给这些类似的链接类“com.company.view.design.Content1”等。在我的主代码库中,我有一个名为 com.company.view.View 的类,它扩展了 com.company.view.design.ViewDesign。这使我可以完全访问视图符号内的所有内容,这很棒,并且视图中的所有时间线脚本仍然有效。

问题是这样的 - 这 3 个内容符号确实很复杂,并且是链接到它们自己的外部类(com.company.view.Content1 等)的主要候选者,但如果我尝试在 Flash 中执行此操作,当我实例化 com 时.company.view.View 我收到错误“类型强制失败:无法将 flash.display::MovieClip@20bec5e1 转换为 com.company.view.Content1”。

那么有没有解决这个问题的方法,或者我只需要将我的 SWC 视为更多的库并以编程方式构建视图,使用与我用于视图的内容窗格相同的继承模式?我希望我的设计师能够处理尽可能多的布局,但随着视图越来越复杂,我不想将单个视图的所有功能放入一个整体类中(com.company .视图.视图)。

I'm working on a very graphic-heavy application which uses content from a bunch of different FLAs. I'm a coder, though, so I want to do all my coding in Flash Builder, however I want to allow my designer to still use a few timeline actions such as stop(); and even a few simple button handlers to change the view. I've been trying to find the best workflow for this sort of setup; I've tried using Embed, but that strips the timeline code, I've tried Loader but that didn't give me any code completion or compile-time checking, and I'm currently using SWCs along with custom classes to subclass elements inside the SWC, which seems to be the best mix so far - you get code completion and timeline scripts still work. The issue I'm having is I have a rather complex view in Flash, and I'd like to assign real classes to some of the other assets in the library, but they don't maintain their class association when exported in the SWC.

As an example, assume I have an FLA with a symbol in the library called View. I give this a linkage class of "com.company.view.design.ViewDesign". Inside this view are 3 frames, with a different symbol on each, called 'content1', 'content2' and 'content3'. I give these similar linkage classes "com.company.view.design.Content1" etc. In my main codebase, I have a class called com.company.view.View which extends com.company.view.design.ViewDesign. This gives me full access to everything inside the View symbol, which is great, and all the timeline scripts in View still work.

The problem is this - those 3 content symbols are really complex, and would be prime candidates to link to their own external classes (com.company.view.Content1 etc.) but if I try to do that in Flash, when I instantiate com.company.view.View I get the error "Type Coercion failed: cannot convert flash.display::MovieClip@20bec5e1 to com.company.view.Content1".

So is there any solution to this, or do I just need to treat my SWC as more of a library and build the view programmatically, using the same inheritance pattern for the content panes as I'm using for the View? I'd like my designer to be able to handle as much layout as possible, but with more and more complex views, I don't want to have to be putting all the functionality for a single view into one monolithic class (com.company.view.View).

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

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

发布评论

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

评论(3

ぇ气 2024-08-18 00:54:33

正如您所说,SWC 是可行的方法。
我想我遇到了非常相似的情况,我建议您 检查这个问题这里 是该方法的一个虚拟项目。

另外,如果它可以加快开发时间,我做了这个 微型扩展,用于声明阶段实例、初始化它们并将它们放入剪贴板中,以便您可以将其添加到链接的类中。您最初需要做的就是在 Flash 面板中设置命名方案,然后您需要的就是“生成”按钮。

我希望你的设计师已经安装了 SVN。设计师讨厌SVN!您可以使用在 Mac 上看起来很可爱的东西来欺骗他们,例如 版本基石

祝你好运!

As you said SWC is the way to go.
I think I ran into a pretty similar situation, and I recommend you check this question out.Here is a dummy project on that approach.

Also, if it might speed up development time, I've made this tiny extension that declares the stage instances, initializes them and puts them in your clipboard so you can add that to your linked class. All you need to do initially is setup a naming scheme in the flash panel, then all you'll need afterwords is the Generate Button.

I hope you designer has SVN setup. Designers hate SVN! You can trick them with something that looks cute on a mac like Versions or Cornerstone.

Goodluck!

凉薄对峙 2024-08-18 00:54:33

您的 com.company.view.Content1 类是否扩展 MovieClip ?
如果不是,则无法将它们添加到舞台中,Flash 将抛出该错误。

do your com.company.view.Content1 classes extend MovieClip ?
If not they cannot be added to the stage and Flash will throw that error.

青柠芒果 2024-08-18 00:54:33

在运行时加载剪辑时,所有类信息都会丢失。这就是你问题的根源。在这种情况下,我成功地使用了以下技术。该技术有助于加载电影并重建类信息。 Grant Skinner 不久前详细介绍了这一点,这也适用于纯闪存应用程序,尽管本文讨论的是 Flex。

When loading clips at runtime all class information is lost. that is the root of your problem. In such cases I have used the following technique successfully. This technique helps in loading the movie and reconstituting the class information. Grant Skinner detailed this some time ago and this holds good for pure flash applications too, even though the article talks about Flex.

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