Understanding the ActionScript Language > About data types > Object

 

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(100);

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 your own objects to organize information in your movie. To add interactivity to a movie 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 allows you to organize this information into groups, simplify your scripting, and reuse your scripts.