ActionScript Variable

A variable is a container where we can store data. ActionScript uses different datatypes for variables.

The syntax for creating or declearing a variable in Actionscript is
var varName:Datatype;

Var is a keyword that defines a variable. Variable name can be any name but it should only consists of letter, numbers, underscrore and dollar sign. Name of variable should not begin with numbers. By convention the first letter of variable is lower case and the subsequent are lower case. For example myVar. A practicle example of declearing null variable in actionscript is given here

var myVar:Number;
myVar = 5;

we can assign values to our variables using assignment operator (=). In the above example we have assigned value 5 to our myVar variable. trace() is a function that will output the value of our variable, myVar. We are going to discuss functions in later topics.


Actionscript is case sensitive language, so keywords should be typed as defined. Actionscript Primitive Datatypes are
Number for example 7.09
int for example  -44, 66,
uint for example  77,
String for example "hello"
Boolean for example  true, false