Variables in ActionScript
Notes:
Variables in ActionScript Programming Language:
Variables Vs. Constants in Action Script - Par 1:
Variable:
Variable is a named memory location, whose value may change during the execution of a program.
Constant:
Constant is a named memory location, whose value never changes during the execution of a program.
I.e. constants stay constant whereas variables vary.
In order to grab a chunk of memory location and provide a meaningful name to it, we need to declare a variable or a constant.
Declaring a variable or a constant: means allocating a memory location for some data
In order to change the value in a variable or constant, we need to initialize or assign a value to it.
Initializing a variable or a constant: means putting a data value in that allocated memory location
Syntax:
var nameOfVariable:datatype; // declaration of a variable
nameOfVariable = value; // initialization of a variable
const NAME_OF_CONSTANT:datatype; // declaration of a constant ( lead to a warning)
NAME_OF_CONSTANT=value; // initialization of a constant (lead to an error)
Note:
By default the value of a variable or a constant, depends up on the type of a variable or constant.
Always initialize a constant when it is declared.