Game Development Reference
In-Depth Information
The keyword eilknp does the importing for you. The Ikrea?hel class is part of another package
called `eolh]u. The `eolh]u package contains a number of classes that—logically enough—help you
display things on the screen. The `eolh]u package itself resides in another folder called bh]od. All of
Flash's built-in classes are in the bh]od folder, so you must use the keyword bh]od to remind Flash of
this. The dots (.) that separate bh]od, `eolh]u, and Ikrea?hel indicate their relative positions in the
directory structure. You're simply saying, “Hey Flash, I need the Ikrea?hel class from the `eolh]u
package that's in the bh]od folder.” This translates rather prosaically to this:
bh]od*`eolh]u*Ikrea?hel7
And don't forget the semicolon! You don't need to worry about where Flash actually goes to get all
this, but you do need to remember that if you need to borrow any of Flash's built-classes, this is the
format you have to use. Later in the topic, when you start working with more than one package, you'll
use this same format to import your own classes into other new classes that you'll have written from
scratch.
If this seems like suddenly a lot to absorb, don't worry! Importing classes to use with
your programs is very routine, and you don't need to feel that you have to memorize
all these technical details right now. You'll do a lot of importing of many different
classes throughout the course of this topic and you'll soon become comfortable with
this format.
7. The next step is to tell your I]ej class to use all the properties and methods of the newly
imported Ikrea?hel class to help it display things on the screen. This is called extending the
class, and you can extend your I]ej class by modifying the following line in bold:
l]_g]ca
w
eilknpbh]od*`eolh]u*Ikrea?hel7
lq^he__h]ooI]ej atpaj`oIkrea?hel
w
lq^he_bqj_pekjI]ej$%
w
pn]_a$ÎDahhkSknh`Ï%7
y
y
y
It's very simple; you just need to add the keyword atpaj`o, followed by the class you want to use; in
this case, the Ikrea?hel class.
As discussed, importing and extending a class is called inheritance. It will not be at all obvious to you
how it works at this stage, so don't worry too much if you don't really understand what's happening or
why you need to do this. Later in the topic you'll see some detailed examples of exactly how this works
and learn what a thing of heady and terrifying power inheritance can be. It will be fun!
 
Search Nedrilad ::




Custom Search