Foundation Game Design with ActionScript 3.0, Second Edition

Foundation Game Design with ActionScript 3.0, Second Edition by Rex van der Spuy Read Free Book Online Page B

Book: Foundation Game Design with ActionScript 3.0, Second Edition by Rex van der Spuy Read Free Book Online
Authors: Rex van der Spuy
file that you do all your work in, but it's not your finished product.
    Your finished product will be an SWF file. This is a file with a .swf extension. It's the file that will run in the Flash Player in a web browser and it's the file that you can upload to the Internet or share with others. The act of creating a SWF file is known as compiling it. (It's also known as building it, which is where Flash Builder gets its name from.)
    There are two ways you can compile an SWF file in Flash Builder.
You can select RunRun from Flash Builder's main menu, or click the green play icon in toolbar. When you do this, Flash Builder builds the SWF file for you in the bin-debug folder in your project directory. It then launches it in the Flash Player.
You can select RunDebug from the main menu, or click the little beetle icon in the toolbar. This is a better option. This does the same thing as the ordinary Run command, but it also opens the Console window. The Console window will display any
trace
directives you used in your program. It will also give you error messages in the Problems window that tell you if you've made some mistakes in your program. When you choose the Debug option, it actually runs the program and launches the debugger. Two for the price of one!
    You'll be using the Debug option almost exclusively when you make your games because the information it gives you in the Console and Problems window is extremely useful. Let's find out how by debugging your program and seeing what happens!
    From now on, I'm going to refer to the debug option as compiling. Whenever I ask you to compile your program in this book, hit that little beetle button.
    1. Select RunDebug from the main menu or click the little beetle icon in the toolbar, as shown in Figure 1-30 . Flash Builder may ask you if you want to save your work before continuing. If you've run the debugger for this program before, it may ask you if you wish to terminate any existing debugging session. In both cases, click the OK button. It may also ask if you want to open Flash Builder's debugging perspective . If it does, select No. (You'll find out what the debugging perspective is and how to switch to it if you want to near the end of this chapter.)

    Figure 1-30. Choose one of these two possible ways to compile your program.
    If Flash Builder is installed properly and you've followed all the instructions in this chapter to the letter, here's what will happen:
Flash Builder will launch a Flash Player window. It will be blank. That's just fine; it should be! (If you didn't deselect the “Generate HTML wrapper file” option in the Project Properties panel, a blank web page will open instead. Refer to the section “Tell Flash Builder to Run Your Programs in the Flash Player” near the beginning of this chapter to prevent this from happening.)
Flash Builder will also open the Console window. You should see the words, “Hello World! Can you read this?” in the Console window. Figure 1-31 illustrates what you should see. The Console window will also display some technical information that confirms that it has created the SWF file, which is your finished work.

    Figure 1-31. Compile your program and see the result in the Console window.
    If this is what happened when you compiled the program, congratulations, you've programmed and run your first computer program! If this didn't happen and you got some sort of strange error messages that you didn't understand, continue reading to see if you can figure out where the problem might lie.
What happened when you compiled the program
    Let's assume for a moment that your program worked perfectly, you saw the result I described in the previous section, and you didn't get any error messages. Here's what happened:
    When you clicked the Debug button, Flash Builder sent your program to something called the compiler . The compiler is a piece of software that is part of the Flex SDK. Its job is to take AS3.0 code and turn it into an SWF file that

Similar Books

My Story

Elizabeth J. Hauser

Love Inspired May 2015 #2

Missy Tippens, Jean C. Gordon, Patricia Johns

The Turning-Blood Ties 1

Jennifer Armintrout

Stars (Penmore #1)

Malorie Verdant

The Summerland

T. L. Schaefer

Plunge

Heather Stone