开发者

ActionScript 3 Workflow using SWCs with linked external classes

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 abl开发者_Python百科e 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).


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!


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜