Variables are a core construct of computer programming.
What is a variable
What is a variable, you ask? The short answer: A variable is a user-defined container for holding data for you in the course of running your program.
If you want to think of a real life analogy, you might think about a variable being like a bucket. A bucket can hold all sorts of things, water, soup, sand, snails, etc. In Flash, a variable can hold different types of data. (Most notably, String, Number, Array, Boolean, and Object. We'll get into those more later).
Defining a variable.
Defining a variable in Flash is as easy as naming it and giving it a value. First you need to make up a name for your variable.
myVar=1;
Here are some things to think about when you're declaring variables:
Variables should be named something that makes sense. One of the good things about modern programming languages like Actionscript is that you have a lot of flexibility in how you name your variables. You should come up with particular conventions in naming your variables. Here are some good examples:
dayArray=["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
currentPage=1;
leftBoundary=25;
You might notice one common convention, and that is with capitalization of each word in the variable name. That helps make it human-readable, which is very helpful in understanding and debugging your own code.
The other thing that is important here is the fact that the variable names are descriptive of what they are for.