Game Development Reference
Understanding Interactive Objects
AS3.0 is what's known as an object-oriented programming language (OOP). Objects are at the core of
everything you do, but what are they? Objects are just “things” that you can control with programming
code. Those objects can be graphics, animations, videos, buttons, or sounds—really anything at all. I'll
be discussing objects in much more detail a little later on, but for now all you need to know is that an
object is something that you want to be able to control and program.
If you've heard or read about object-oriented programming before now, you might have bumped
into other words surrounding the phrase such as “advanced” or “not for beginners.” Actually, nothing
could be further from the truth. By learning about objects right from the beginning and understanding
how to control them, doors of understanding will start to open up for you that will provide you with
immense control over your programming code in a very short time.
Over the next few pages you'll create your first objects: three scenes for an interactive children's sto-
rybook. You'll then create some buttons to control those objects. In Chapter 3 you'll learn to program
those buttons using event listeners, and in Chapter 4 you'll add some characters to the pages and
control those characters using properties. But you can just file that away for later because you'll take
just one small step at a time.
If you've used Flash, creating objects is an almost laughably simple process that you've probably
already done many times without even realizing it. If you haven't used Flash very much, don't worry;
I'll cover everything you need to know in detail in this chapter.
There are two ways to create objects in Flash. You can create them with AS3.0 programming code or in
Flash's visual authoring environment. One of Flash's great strengths as a game development platform is
that it enables you to draw and animate complex objects without having to look at a single line of code and
then use those objects anywhere in your program. This is a huge time-saver, and it's also loads of fun!
In the next example, you'll draw three scenes for a children's interactive storybook and set them up as
objects that you can control with code. This chapter will cover the following topics:
Flash's vector drawing tools
Creating symbols in the Library
Instances and the stage
In this chapter, you'll make these objects; in the next chapter, you'll program them.
Setting up the work environment
Your first job is to create the files that you'll need for this project. Like the Hello World program from
Chapter 1, you need to start with an FLA and an AS file. You'll create the FLA and then use it to create
a Quick Project in Flash's Project panel.
1. Find a convenient spot on your hard drive and create a project folder called
2. Open Flash. Select File ° New and choose Flash File (ActionScript 3.0) from the New Document