User Guide
34 Chapter 2: ActionScript Basics
Constants
A constant is a property whose value never changes. ActionScript contains predefined constants.
For example, the constants
BACKSPACE, ENTER, SPACE, and TAB are properties of the Key object
and refer to keyboard keys. To test whether the user is pressing the Enter key, you could use the
following statement:
if(Key.getCode() == Key.ENTER) {
alert = "Are you ready to play?";
control_mc.gotoAndStop(5);
}
Flash does not enforce constants; that is, you can’t define your own constants.
About data types
A data type describes a piece of data and the kinds of operations that can be performed on it. That
data is stored in a variable. You use data types when creating variables, object instances, and
function definitions.
ActionScript has the following basic data types that you will probably use frequently in your
applications:
• “String data type” on page 35
• “Number data type” on page 36
• “Boolean data type” on page 36
• “Object data type” on page 37
• “MovieClip data type” on page 37
• “Null data type” on page 39
• “Undefined data type” on page 39
• “Void data type” on page 39
ActionScript also has built-in classes, such as Array and Date, that can be considered complex
data types. For more information, see “Using the Built-In Classes” on page 197. If you are an
advanced developer, you might create custom classes. Any class that you define using the
class
declaration is also considered a data type. All built-in data types and classes are fully defined in
Flash ActionScript Language Reference.
Variables containing primitive data types behave differently in certain situations than those
containing reference types. (See “Using variables in a program” on page 47.) There are also two
special data types: null and undefined.
When you debug scripts, you might need to determine the data type of an expression or variable
to understand why it is behaving a certain way. You can do this with the
instanceof operator
(see “Determining an item’s data type” on page 43).
WebServiceConnector Window XML XMLConnector
XUpdateResolver