Object

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 allows you to 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

You can use the built-in ActionScript objects to access and manipulate specific kinds of information. For example, the Math object has methods that perform mathematical operations on numbers you pass to them. This example uses the sqrt() method:

squareRoot = Math.sqrt(50);

The ActionScript MovieClip object has methods that let you control movie clip symbol instances on the Stage. This example uses the play() and prevFrame() methods:

mcInstanceName.play(); mc2InstanceName.prevFrame();

You can also create custom objects to organize information in your Flash application. To add interactivity to an application with ActionScript, you’ll need many different pieces of information: for example, you might need a user’s name, the speed of a ball, the names of items in a shopping cart, the number of frames loaded, the user’s ZIP Code, or the key that was pressed last. Creating custom objects lets you organize this information into groups, simplify your scripting, and reuse your scripts.

Object