As we just learned, ActionScript programs are made up of classes, which are the blueprints for the interoperating parts (objects) of a program. Typically, the development of a new ActionScript program starts with a design phase, during which the program's functionality is broken into a logical set of classes. Each class is given a name, a set of features, and a role in the larger program. One class in particular is designated as the main class. The main class provides the starting point, or program point of entry, for the application. To start a new program, the Flash runtime automatically creates an instance of the program's main class.
For our virtual zoo example program, we'll name the main class VirtualZoo. As the first step in building the program, we'll create a folder on the filesystem, named virtualzoo. Within that folder, we'll create a subfolder named src (short for source) in which to store all .as files (i.e., all files containing source code).
Each program's main class code must be placed in a text file named after the main class, and given the extension .as. Accordingly, we'll create an empty text file named VirtualZoo.as. Notice that the filename VirtualZoo.as exactly matches the class name VirtualZoo and that case sensitivity matters. We'll place VirtualZoo.as in the folder virtualzoo/src. Here's the file structure for our program's source files so far:
virtualzoo |- src |- VirtualZoo.as
With VirtualZoo.as created, we can start writing the VirtualZoo class. However, first we must deal with a potential problem—if our chosen main class name conflicts with (i.e., is the same as) one of ActionScript's built-in classes, then ActionScript won't let us create the class, and our program won't be able to start. To prevent potential naming conflicts in our program, we use packages.
There is a lot of ground to cover, so we won't actually compile our zoo program's code until Chapter 7. If you decide to jump ahead and compile the examples presented in Chapter 1 through Chapter 6, you are likely to encounter various warnings and errors. After Chapter 7, you'll be able to compile all versions of the example program without errors.