Confessions of a Flash Purist

Jed Wood posted a comment on the first installment of my Hands-on:Introduction to ActionScript 2 tutorial series, asking: "While I admire your desire to have NO lines of code in your .FLA (not even a "main(), such as Colin Moock suggests"), doesn't this necessitate that you manually place movie clips on the timeline at author time (at least one)? That seems to go against being a code purist..."

I was in the process of replying in the comments when I realized that I had written enough for a post, so here goes:

Thanks for posting the question, it's an important one.

I don't necessarily believe that not putting code inside your FLA makes you a "code purist". That's definitely not a term I would use to describe myself. Quite on the contrary, I am quite opposed to doing everything through code in Flash. Let me tell you why:

Flash is a unique beast. It gives us a rich visual playground on which to rapidly lay out user interfaces and create frame animations. It would be a shame to not make use of these features. I know some people like to do everything by code -- attaching every component at runtime -- and, again, I cannot say that this is a bad way of doing things as there is no "One Right Way" to development. I do believe, however that using Flash in this manner deprives you of some powerful and time-saving features that you could otherwise make use of.

I lay out all of my forms visually, on the stage. This lets me easily prototype and visualize my UI. I can also print this out and do paper-based usability tests in an instant. For forms that do not need to change their layouts at runtime, this is all I need to do. If a form does need to dynamically lay itself out, say, in response to size change events on the Stage, I write that code but still keep the visual layout as a guide. It doesn't cost me anything and helps me conceptualize things better.

Regarding using a main() method as the point of entry into a Flash application: I find it somewhat forced and artificial. It is a tribute to Java without doubt but I do not subscribe to the school of thought that Java is the end-all be-all of programming languages. (C# is currently my favorite but I'm not married to it either!)

Having a main() method makes sense in Java and, of course, can be made to work in Flash. I find it much more intuitive and "Flash-like", if you will, to allow the natural order of things to provide the entry point. An application form that contains child forms will initialize after all of its children have, neatly providing you with your entry point. Lines of code written to achieve this: Zero! Flash does all the work! :)

For an example of how this works in larger applications, take a look at the sample applications in the Ariaware RIA Platform (ARP 2.0) documentation.

So, if anything, I would say I'm a "Flash purist" -- I try to vibrate in sync with Flash and find that when I do, Flash tends to help me out in surprising ways and we tend to get along together rather famously!