Ideas for asset and code separation

I had an idea this afternoon for simple asset from code separation in Flash8/AS2. You might have been in the situation were you wanted to load in your views, or have your views and other assets external from your code. If these assets happened to be V2 Components you were even having a bigger party.

I am usually working on a kind of hybrid projects, I create a fla with assets and code runnable from the IDE, and use the resulting swf as an injection swf in FlashDevelop. The cool thing of working this way is that -seeing the project is hybrid and all- you can either work on the project in the Flash IDE, or crank some code in FlashDevelop. There are a few drawbacks however.

  • you are using an swf which already contains all code as an injection swf. Since we use only intrinsic mx classes, we can’t use the keep flag to remove all classes from the swf, since we lose the mx classes from the swf. However especially refactoring where new superclasses are introduced or interfaces, requires recompilation of the injection swf in the Flash IDE. And in general it’s bad practice, and bloates your swf
  • you need the code to export the swf from the IDE
  • you need the injection swf to run your application from FlashDevelop

Especially when working with a designer where the designer generates the assets and you the code, this file dependency isn’t optimal. Although there are other options such as using SWFMill or runtime shared assets, they all solve part of the problem, and when one of our graphical designers has to create assets it’s simply the easiest if he/she can create a fla in the IDE without worrying about whether it compiles my source code, etc. Although he could only update his source tree from subversion if I tell him to, he’d still need a subversion checkout and it would require an action on his part.

So I was thinking of trying out the following setup:

  • we already have a specific flash template which contains functionality for things such as:
    • preloading
    • debugging
    • flash version checking
    • swf as dll loading
    • etc
  • what I can add is a config.xml which specifies two things:
    • the application dll to load, this contains all code necessary to bootstrap the application
    • the name of the class to create to start the application

Since no more application code is referenced from the fla, it wont be compiled. Since you are loading the code into the view you won’t have any problems with V2 components. If you want to change the assets, edit the fla template and update the assets.

Ok it’s not uber, but it’s easy enough and an improvement over using code filled injection swf’s :twisted:

It improves the overall development workflow, gives each developer his/her preferred tool to work with, seperates code from graphics, keeps you from messing with eachothers files etc…

I’ll try it out somewhere next week and post an example (but 220BPM is probably first on my list :) )

Leave a Reply