views:

579

answers:

3

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).

+1  A: 

Hi Ken,

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!

George Profenza
George, thanks for the link, I actually read your post before and had the same 'shared classpath' issue you did, so that was incredibly helpful information! Unfortunately, my problem is more complex in that I can't link in nested custom classes. I can link one symbol in the library to a custom class, export a SWC and get the functionality. But, if that symbol has another symbol inside of it, say a custom button with a similarly linked class, the button won't be typed in ActionScript. I think the solution is going to be to simplify the FLAs so nothing's nested, and assemble my layout in script.
ken.dunnington
Oh, forgot to add, I always make my designers use SVN :)
ken.dunnington
It's a bit of a chicken an egg thing. If you link to classes in flash and compile the swcs, you run into the Type Coercion error. On the other hand, if you use the default generated as3 classes by flash with the swc, and you subclass that:you get nothingness.the swc contains precompiled classes which act weird when subclassing. As you said, splitting it up might be the way forward. Have a different swc for each component maybe, and redo some of the menu animations with code. Adobe seems to considered integration with flash when it comes to the flex framework mostly :( what about the basics ?
George Profenza
A: 

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

Cinegod
A: 

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.

http://bit.ly/nwS6J.

vijayshan