Understanding the ActionScript Language > About variables |  |

About variables

A variable is a container that holds information. The container itself is always the same, but the contents can change. By changing the value of a variable as the movie plays, you can record and save information about what the user has done, record values that change as the movie plays, or evaluate whether a condition is true or false.

It's a good idea always to assign a variable a known value the first time you define the variable. This is known as initializing a variable and is often done in the first frame of the movie. Initializing variables helps you track and compare the variable's value as the movie plays.

Variables can hold any type of data: number, string, Boolean, object, or movie clip. The type of data a variable contains affects how the variable's value changes when it is assigned in a script.

Typical types of information you can store in a variable include a URL, a user's name, the result of a mathematical operation, the number of times an event occurred, or whether a button has been clicked. Each movie and movie clip instance has its own set of variables, with each variable having its own value independent of variables in other movies or movie clips.