AS 3: Setting Up a Document Class
Mar 18th, 2008 by Leo Geis
The Document Class isn’t a predefined Class in ActionScript-it’s whatever Class you specify in your Document (.fla file) to serve as the root of the application. Thus, The Document Class serves as the DisplayObjectContainer into which all other components of your Documents DisplayObjects and DisplayObjectContainers will reside (aside from the Stage, of course…).
The Document Class is specified in the Properties Inspector or in File>Publish Settings>Flash>ActionScript version (click the Settings… button). It constructs as an .as file external to the .fla via File>New>ActionScript File.
The cardinal strategy of the Document Class is to relieve any Frame Scripting-to formalize the code writing to a single Class that represents the entire application, facilitating formal Object Oriented Programming.
Because of the nature of aerial photographic portfolios and the types of animations and interactivity we will (eventually) be applying to them, we will base our applications on Document Classes as opposed to Frame Scripts. Until the time that we deliberately move to that format, please don’t hesitate to use Frame Scripting and Procedural Programming techniques-it’s just that the Document Class is so often discussed and used in demonstrations that you’ll probably encounter it in your research and you should know what it is-and isn’t.
The Document Class must extend Sprite or its subclasses MovieClip, HTMLLoader, FLVPlaybackCaptioning, or UIComponent. For our purposes we’ll use Sprite when a timeline is unnecessary, or MovieClip when one is.
The stage Property of the Document Class is accessible since the Document Class is a Child of the Stage. Normally, the Stage is accessible only through the stage Property of a DisplayObject or DisplayObject Container that is on the Display List.
(Click for larger image-or right-click to open it in a New Window). The start of something beautiful. Note that our Document Class for the documentclassdemo.fla is specified in the Document class Window, and that our documentclassdemo.as imports and extends Sprite. A more qualified Classpath is not necessary for the Package since it is sitting alongside the .fla, and our Constructor Function is already started in the Class definition.
L



