
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
314
|
Chapter 12: Objects and Classes
Built-in Objects
Like built-in classes, built-in objects let us control the movie environment. The Key
object, for example, defines a series of properties and methods that tell us about the
state of a computer’s keyboard. To use these properties and methods, we don’t
instantiate a Key object, we simply use the Key object directly. Built-in objects are
made automatically by the interpreter when the Flash Player starts, and they are glo-
bally available throughout a movie.
Here, for example, we display the keycode of the currently depressed key by invok-
ing the Key object’s getCode( ) method:
trace(Key.getCode());
And here, we check whether the spacebar is depressed, using the isDown( ) method
and supplying the spacebar’s keycode as an argument:
trace(Key.isDown(Key.SPACE));
In the Language Reference, you’ll learn about the other built-in objects.
Learning the Ropes
Learning to write valid ActionScript code is only half the job of learning to program
in Flash. The other half comes with learning the available built-in classes and objects
and their many wonderful properties and methods. We’ll undertake that task in the
Language Reference. However, it’s not necessary to study all the classes and objects
in one sitting. Learn about movie clips to start, and ...