Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change.Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.

Page tools

In ActionScript, a variable is a mechanism for storing data. The current value of the variable is the data actually stored in the variable. The data stored in the variable can be intentionally altered during runtime, causing its value to change—or vary—which is why they are called variables. You use identifiers to reference variables by a specific name.

An identifier referencing a variable can be used to access the variable in order to read out the value, alter the value, or reset the attributes of the variable, such as an object's speed, color, or location. For instance, a variable might be referenced by the identifier propel and the variable contains a numeric value to indicate the speed that an object animates. A variable definition looks like this:

var propel:Number = 5;

The scope of a variable describes where the variable may be used in a program's text. The extent (also known as a variable's lifetime) describes the span of time within the project's execution that a variable has a (meaningful) value. The scope of a variable is actually a property of the name of the variable, and the extent is a property of the variable itself:

To call a variable that is outside a function, you can create a path to it using the dot syntax like this:

mcBoat.x += mcEngine.propel;

To learn more about working with variables, see the section titled Variables in Learning ActionScript 3.