O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Compiling with Flex Builder 2

Before we can compile the virtual zoo program using Flex Builder 2, we must first make some changes to our code in order to meet the requirements of Flex Builder 2's compiler. Flex Builder 2's compiler stipulates that a program's main class must reside in the unnamed package. Currently, our VirtualZoo class resides in the package zoo, not the unnamed package.

Moving the Main Class to the Unnamed Package

To move VirtualZoo from zoo to the unnamed package, we must follow these steps:

  1. Move the file VirtualZoo.as from /virtualzoo/src/zoo to /virtualzoo/src/.

  2. In the VirtualZoo.as file, add the following code immediately before the VirtualZoo class definition statement (this code imports the classes from the zoo package):

    import zoo.*;
  3. In the VirtualZoo.as file, remove the package name "zoo" from the package declaration statement. That is, change this code:

    package zoo {

    to this:

    package {
  4. In the VirtualPet.as file, change the access-control modifier for the VirtualPet class from internal to public, as follows (this gives the VirtualZoo class access to the VirtualPet class):

    public class VirtualPet {

Once the preceding changes have been made, we can then compile the program.

Compiling the Program

To compile the virtual zoo program, we first create an ActionScript Project, as described in the following steps:

  1. Select File → New → ActionScript Project.

  2. On the New ActionScript Project dialog, for Project name, enter virtualzoo.

  3. Under Project Contents, uncheck "Use default location". ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required