Variables are information holders. Think of them as boxes with labels. The labels are the variables' names and the contents are the variables' values. Below are a few details about variables and how to use them.
Sometimes, it helps to have a naming scheme for your variables. Say, for instance, that you always begin your variables with a capital letter and follow them with only lower case letters. This can help you distinguish variable names later on.
Score = 6000;
Local variables can be declared within any function or block of code by using the "var" function. Such variables will be erased after the block of code or script is finished running. An example of a local variable declaration is below:
var DogsLeftToPet = 10;
Numbers are numerical values that Flash can use in mathematical expressions and equations. When a variable has been assigned a numerical value, it can be manipulated just as if it were that value. See our example below.
DogsLeftToPet = 10;
DogsPettedToday = 3;
DogsLeftToPet = DogsLeftToPet - DogsPettedToday;
DogsLeftToPet => 7
Strings are groups of characters. Flash doesn't really understand what they mean, but it can shuffle them around and compare them. To assign a string value to a variable, use quotation marks around your data. See the example below.
FavoriteIceCream = "Rocky Road";NOTE: You can have a variable that holds a string of numbers. The Number and String functions in the ActionScript Library help you change data from a string to a number and back.
Learning to use variables is an important step in learning to program effectively. Be sure to read the above information carefully before moving on.