You want to add custom properties (variables) to an object (an instance of a class).
Attach the new property to the object using an assignment statement and the dot operator.
Objects derived from the built-in ActionScript classes have standard
properties. For example, arrays have
properties, movie clips have
_y properties, and
duration properties. But aside from these standard
properties, you can add custom properties to any object in
ActionScript. You can add new properties to an object (or change an
existing property’s value) by simply assigning the
property a value. If the property does not yet exist, ActionScript
creates it automatically.
myMovieClip.myProperty = "some value";
Custom properties of movie clip
objects are sometimes referred to as
timeline variables, as discussed in Recipe 1.12. However, you can apply the same
principle not only to movie clip objects, but to any kind of object.
For example, the following code adds a custom property to an array
myArray.myProperty = "some value";
Attaching properties to objects is invaluable. For example, custom properties can store a value that is used internally within an event handler method (or any other method) of the object. You can initialize the property value outside any of the methods and then access it within a method. This technique creates a variable whose value persists between function invocations ...