Coding in Flex Builder, Compiling in Flex Builder: A Better Flash Workflow
A couple of weeks ago, I posted about a workflow I had devised that allowed me to utilize Flash library symbols but still write my code in Flex Builder. While Adobe apparently thinks this awkward hybrid approach qualifies as “integration”, I thankfully discovered a better process just a day or so after my posting. I discovered the main concept of this better workflow from Arpit Mathur’s blog.
What it basically boils down to is using Flash authoring to create a SWC that you then use as a library in your ActionScript project in Flex Builder. Getting Flash authoring to generate a SWC is as simple as checking a box in the Publish Settings dialog.

Then make your ActionScript project use the resulting SWC.

What you can then do is create ActionScript classes that extend the symbols in your Flash file. As long as you give your symbol a linkage name it will be available for extension (and will itself extend MovieClip by default), allowing you to add behaviors and logic using class-based ActionScript like developers expect and prefer to do. The convention I have settled on is to add “_Symbol” to the end of the class names specified in Flash authoring to make it completely clear where everything originates.

The other major advantage this approach has is that it renders the “Automatically declare stage instances” debate irrelevant. You can let the designers leave this setting off and write bits of timeline code if they need to and your classes that extend their symbols will still work. Regardless if they are specified manually in class files for the symbols themselves or Flash generates the classes automatically, the children of your symbols (text fields, child movie clips, etc.) will all be available to your code.

With this simple structure of a symbol in Flash:

You can write a class like this to control it.
The result is a functioning button that allows the designer to use the expressive, proven tools in Flash authoring to create the graphical assets while allowing the developer to use the mature code editing environment of Flex Builder. This process has proven valuable and efficient over the last two weeks and it addresses the major shortcoming of my previous post. That was an inability to use a proper debugger, and it also lets the designer and developer work in parallel, both in the environment most familiar to them. It lets each tool and each team member do what they do best.
While I developed this workflow (not that its an original one by any means, just new to me) due to my assignment on a project that could not use Flex, I actually think it could be valuable in Flex projects as well. For views that are highly detailed and/or non-standard it may very well be easier to let your designer create them in Flash than it would be to create some crazy MXML file that carefully layers exported images and animations that you then try to wire up and orchestrate with code. Simply write a class that extends your designer’s symbol and manipulates it as needed.
To me this seems like the best kind of workflow available today by far, and so its really disappointing and frustrating to think Adobe may not be taking things a step further in their next releases. We don’t need or want Flash Builder to compile and run our projects in Flash authoring. What we need are workflows that allow us to use tools that do their job well and that we’re comfortable with, and that simplify the inevitable round tripping between design and development. Having Flash Builder trigger compiles in Flash authoring may sell more licenses to the uninformed, but its a sad excuse for integration from a company that creates tools ranging from authoring to runtime.
All code and sample files for this post can be found in my Google Code repository.
You can leave a response, or trackback from your own site.

My big issue with this sort of workflow is that if an artist updates the SWC files it still requires a developer with the full source to compile them into the project.
I’ve been spending a lot of time thinking about this exact issue, and I’m currently using a method where developers can compile a pure code swf using mxmlc (either out of FlashDevelop or FlexBuilder) and artists have their own separate art FLA with “stage instances” turned off – so that the code SWF can play with all of those instances without compile time errors, but with great separation between roles.
You just test in a browser, and the art files load the core of the project in. (The code files.) Since the art is the parent, the code has access to all of the library objects, and the actual assets are attached to the classes that the code side is already using.
I’m going to write up a post on how it’s structured in a bit, but I’m enjoying it so far.
I also really like having to make custom classes that declare what the stage instances are – it’s built in documentation for new developers that come onto a project.
Simple and clever. Thanks !
That’s the exact same workflow that I use.
I always wondered if it was broadly accepted as “proper”
That is actually not the case regarding the designer being unable to compile. If your FLA uses the document class construct (which I mentioned in the first article) and you add the proper class paths you can run the application right from Flash authoring.
In your workflow, how does the developer see the progress they are making as they code? It seems like it would be an awkward process to compile a SWF of your code but launch a different SWF and then have the code loaded in. It obviously depends on the project and the team, but thinking of the code as a child of the graphics also seems very counter intuitive to me.
Regardless, thanks for sharing your approach. The more options people see the easier it is to figure out what works for them.
Exactly what i do. It makes me wonder though – What is the point of flash catalyst?
Good question.
Our preferred workflow too when working with FlashDevelop – win in code completion, win in compilation time.
People complaining about the “artist updates the SWC” are just boring: if something has to be updated “easily” just keep it as an external SWF.
I didn’t mean that an artist couldn’t compile out of the Flash authoring environment if they had all the right files, I just meant that with this method anyone that wants to compile has to have all the source code and such.
The benefit of the method I use (which I agree is a little counter-intuitive – code should be the parent!) is that our artists don’t even have to have the source code anywhere on their machine. They can work totally independently, and make as many art changes as they want without even touching the code files – since their main art file has a small bootstrap that loads in the code, which then uses the parent definitions from the art SWF.
I’ll make a post about it and let you know; it sounds really convoluted when I try to explain it briefly! We use GIT for our source control solution, and it’s just better that artists don’t have to have anything to do with code files, and developers don’t have to have anything to do with art files.
(I should clarify that artists still need the UI classes in the method I use; just that those classes are totally bare bones and contain no implementation, they’re more like UI interfaces.)
What if you needed your behavior and logic classes to inherit from a base class? Since all of your logic classes are stuck extending “dumb” MovieClip symbols, you can never take advantage of logic-level OOP, right? (Excluding hacks to simulate multiple inheritance.)
You should not extend symbol classes unless it is to add behavior to them. In other words, only view classes should extend the symbol classes, not “behavior and logic” classes.
I’m trying to get this workflow to work for a project that I started in Flash CS4. One difference is that in Flash the project is published as AIR 1.5.
Now that I’ve brought the project into Flex Builder and set it up as an ActionScript project, FB does not seem to recognise the AIR specific code even when the correct Class is imported.
For instance, code that allows the application window to be dragged
Main.timeline.stage.nativeWindow.startMove ();
(timeline is a property of the Main Class and refers to the main timeline)
throws this error
1119: Access of possibly undefined property nativeWindow through a reference with static type flash.display:Stage.
even though the Class has this import:
import flash.display.*;
This code works correctly when using Test Movie in Flash.
Any ideas how I get FB to recognise this AIR specific code?
Hi Andrew,
Flex Builder has a specific AIR project type. You would have to say New -> Flex Project, and then in the dialog check the AIR radio button. There is (as far as I know) no concept or reference to the timeline in these projects so you would likely have to redo some code.
HTH,
Ben
I think I worked it out!
Remember this is essentially a Flash project utilising FB solely for code development, so there cannot be any Flex code, just ActionScript.
Therefore I can’t use New -> Flex Project with the AIR radio button as it will add Flex code to the project.
However adding the AIR framework to the ActionScript project in Flex seemed to give FB the “knowledge” of the AIR code it was compiling, so no more errors.
I found the AIR framework (airglobal.swc) under Flash CS4/AIK 1.5/frameworks/libs/air/ in my Applications folder (Mac OSX).
I added airglobal.swc to the Library path in Flex found under:
[~myFlexProject] -> Properties -> ActionScript Build Path -> Library Path
Seems to work!
I see what you’re saying about the word “timeline” but really I’m just using it as a class property, so I’m not sure Flex thinks its a Flash timeline. Its the property nativeWindow which Flex didn’t understand until the AIR framework was added.
Anyway thanks for a marvellous article which is by far the easiest I’ve read on how to use FB for pure ActionScript development.