Contents

Syntax Arithmetic

Script Variables

A variable is used to store data, such as numbers, text, arrays or true/false values. Variables declared in the general event are available throughout the movie. Variables declared in other events are only available in that event. Declare variables using the 'var' command. Variable names can only contain letters and numbers. No spaces are allowed. They can not start with a number. Each variable name can only be created once.


var Name;
var Name1=Value;
var Name2,Name3=Value,Name4;

Example:


var x=5;
var Name="Hippani";
var Test1=true;
var A,B,C;
var CurrentDate=new Date();
var List=new Array("Item1","Item2","Item3");

Variable can be accessed inside blocks of code.


var A="Hello";
if(true)
{
alert(A); //OK
}

Variables created in a block of code cannot be accessed outside of that block.


if(true)
{
var A="Hello";
}
alert(A); //!Error

Syntax Arithmetic