Today, I've been experimenting with project structure and workflows. I've got two major problems I want to solve.
When working in Flex Builder, if you have a lot of non-embedded assets, it can go really slow. At seemingly random times Eclipse will decide it needs to delete all of your output files and re-copy them. For our current project, that can take 10 minutes. We have yet to figure out what triggers this behavior.
When working in Flex builder, if you have a lot of embedded assets, it can go really slow. Especially on clean builds, or builds that touch a lot of modules. This is an every-compile type thing, but is far less severe than problem #1.
Solution for Problem #1
Don't let Eclipse do the copying for you. Put your assets outside of your source tree, and turn off "Copy non-embedded assets". To the right is an example directory structure. There are a few differences than most Flex/Flash builder projects.
- My assets folder is a sibling of my src folder, instead of inside it.
- My compiler is set to output to assets/bin-debug instead of just bin-debug
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="1024" minHeight="768"Since the embed is relative to the source folder, we need to use paths in the form of ../assets/art/
<s:layout> <s:VerticalLayout /> </s:layout> <mx:Image source="@Embed('../assets/art/Image1.png')" /> <mx:Image source="../art/Image2.png" /> </s:Application>
The runtime loaded assets are relative to the final compiled location, so those take the form ../art/
Now, eclipse will never try to manage your assets. This appears to completely solve problem #1.
Solution for Problem #2
A while back I blogged about turning a Flash Catalyst project into a .swc. (Read that here)
I dusted off my script and tried it with the Beta-2 of Flash Builder and Catalyst. And low-and-behold it worked without any changes. The only thing I had to do was reset my FLEX_HOME environment variable to the new location.
So, if we were to move away from a model where we embed assets from designers into Flash Builder, and to a model where the Designer puts those assets into Catalyst, and then we run a script to compile the catalyst project into a .swc, I think that would completely solve problem #2.