Monday, May 12, 2008

Open Source Project Structure

The structure of an Open Source Flash project is different than one developed inside Adobe Flash, the commercial development studio. On the commercial side:
  • A timeline is developed
  • Assets (images, video, and sounds) are created by drawing or recording or added by import
  • ActionScript is written to animate the timeline and assets
  • Projects are saved into a single FLA file
  • Flash files are generated.
On the Open Source side:
  • Imported assets are added to a library
  • ActionScript is written to draw and animate assets, and simulate a timeline
  • Projects are saved into directory structure
  • Flash files are generated
An asset library is an additional SWF file that holds your images, video, and sounds with names. ActionScript classes refer to these assets by their names. When compiling, MTASC accepts an input SWF to supply assets to your code. MTASC will resolve these references correctly.

If you watch demonstration videos (like I do) for Adobe Flash available on various Websites, you will notice users first create an image -- by drawing using vectors or loading a bitmap. Second, they can convert the image to a MovieClip by double clicking. ActionScript code can then be associated with this MovieClip.

In Open Source ActionScript, there are two equivalent processes.

If the image is a bitmap or video, an asset library must first be created. In your ActionScript code, a subclass of MovieClip is created and associated with the asset name. Each time a copy of the asset is placed, the associated class constructor is called.

If the image is drawn using vectors, a pure ActionScript solution is possible. A subclass of MovieClip is created. In the constructor or method, the image is created with drawing functions. A few coding tricks are required to create a subclass of MovieClip without an associated asset. We'll show you how later.

Finally, I have yet to figure out how to fully replicate the Adobe Flash timeline in Open Source ActionScript via gotoAndPlay() and its relatives. Fortunately, there are ways to simulate this same abstract construct without depending upon frames and scenes.

No comments: