User Guide
About data types 37
}
};
submit_button.addEventListener("click", btnListener);
For more information, see “Using built-in functions” on page 60 and “Logical operators”
on page 53.
Object data type
An object is a collection of properties. Each property has a name and a value. The value of a
property can be any Flash data type—even the object data type. This lets you arrange objects
inside each other, or nest them. To specify objects and their properties, you use the dot (
.)
operator. For example, in the following code,
hoursWorked is a property of weeklyStats, which
is a property of
employee:
employee.weeklyStats.hoursWorked
The ActionScript MovieClip object has methods that let you control movie clip symbol instances
on the Stage. This example uses the
play() and nextFrame() methods:
mcInstanceName.play();
mc2InstanceName.nextFrame();
You can also create custom objects to organize information in your Flash application. To add
interactivity to an application with ActionScript, you need many pieces of information: for
example, you might need a user’s name, age, and phone number; the speed of a ball; the names of
items in a shopping cart; the number of frames loaded; or the key that was pressed last. Creating
custom objects lets you organize this information into groups, simplify your scripting, and reuse
your scripts.
The following ActionScript code shows an example of using custom objects to organize
information. It creates a new object called
user and creates three properties: name, age and phone
which are String and Numeric data types.
var user:Object = new Object();
user.name = "Irving";
user.age = 32;
user.phone = "555-1234";
For more information, see “Using classes: a simple example” on page 250.
MovieClip data type
Movie clips are symbols that can play animation in a Flash application. They are the only data
type that refers to a graphic element. The MovieClip data type lets you control movie clip
symbols using the methods of the MovieClip class.
You do not use a constructor to call the methods of the MovieClip class. You can create a movie
clip instance on the Stage or create an instance dynamically. Then you simply call the methods of
the MovieClip class using the dot (
.) operator.
Working with movie clips on the Stage. The following example calls the startDrag() and
getURL() methods for different movie clip instances that are on the Stage: