About operators and variables

You might wonder about the mathematical symbols in your code. These symbols are called operators in ActionScript. Operators calculate a new value from one or more values, and you use an operator to assign a value to a variable in your code. You use the equality (=) operator to assign a value to a variable:

var username:String = "Gus";

Another example is the addition (+) operator, which you use to add two or more numeric values to produce a new value. If you use the + operator on two or more string values, the strings will be concatenated. The values that operators manipulate are called operands.

When you assign a value, you use an operator to define a value to a variable. For example, the following script uses the assignment operator to assign a value of 7 to the variable numChildren:

var numChildren:Number = 7;

If you want to change the value of the numChildren variable, use the following code:

numChildren = 8;

NOTE

 

You don't need to use var because the variable has previously been defined.

For more information on using operators in your ActionScript, see About operators.


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00000658.html