Game Development Reference
In-Depth Information
Your ActionScript editor window should now look some-
thing like Figure 1-5.
What you just created is something programmers call
a block statement . Block statements define a particular
section of the program and are used to group together all
the code between the curly braces. In this case, the pack-
age block statement is completely empty because there's
nothing between the curly braces. But don't worry; it won't
remain empty for long!
Figure 1-5. Create a package in the file.
Before continuing, however, it's worth taking a closer look at exactly what you created.
As you started typing the code in the ActionScript editor window, you noticed that the word package
was automatically colored blue by the editor. This is Flash's helpful way of telling you that what you've
just typed is a keyword—a word it understands. Keywords are also known as reserved words . This
means that those words belong to ActionScript and ActionScript alone; you can't use them as names
you choose to give your packages, classes, variables, or methods (more on them soon). The l]_g]ca
keyword simply tells Flash, “Hey, I'm creating a package!” Not too hard, is it?
After the l]_g]ca keyword come our dear little friends, the curly braces:
Cute, aren't they? At the moment, they're completely empty, but that's about to change very quickly.
Soon you'll put something inside them whegapdeoy.
Don't skip class!
Now that you created a package, the next step is to create a class inside that package. You can think
of a class as a basic building block for creating an ActionScript program.
3. With your ActionScript editor window still open, add the following text in bold, directly inside
the package's curly braces . Notice that this new text is indented from the left margin. Use the
Tab key on your computer keyboard to indent it when you add it to your program. The code
in this topic uses indent levels of two spaces, but the ActionScript editor window indents your
code by four spaces when you press Tab , which is just fine. Very soon you'll see how important
it is to indent your code like this.
You've just created a class called I]ej. (Make sure that the M is uppercase.) Both the words lq^he_
and _h]oo will be colored blue to show you that they're reserved keywords that AS3.0 understands.
It doesn't look like much, does it? And what is a class?
Search Nedrilad ::

Custom Search