Symbolic operators are characters that specify how to combine, compare, or modify the values of an expression.


 Arithmetic
 +additionAdds numeric expressions or concatenates (combines) strings.
 --decrementA pre-decrement and post-decrement unary operator that subtracts 1 from the expression.
 /divisionDivides expression1 by expression2.
 ++incrementA pre-increment and post-increment unary operator that adds 1 to expression .
 %moduloCalculates the remainder of expression1 divided by expression2.
 *multiplicationMultiplies two numerical expressions.
 -subtractionUsed for negating or subtracting.
 Arithmetic compound assignment
 +=addition assignmentAssigns expression1 the value of expression1 + expression2.
 /=division assignmentAssigns expression1 the value of expression1 / expression2.
 %=modulo assignmentAssigns expression1 the value of expression1 % expression2.
 *=multiplication assignmentAssigns expression1 the value of expression1 * expression2.
 -=subtraction assignmentAssigns expression1 the value of expression1 - expression2.
 Assignment
 =assignmentAssigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1.
 Bitwise
 &bitwise ANDConverts expression1 and expression2 to 32-bit unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters.
 <<bitwise left shiftConverts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the left by the number of places specified by the integer resulting from the conversion of expression2.
 ~bitwise NOTAlso known as the one's complement operator or the bitwise complement operator.
 |bitwise ORConverts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1.
 >>bitwise right shiftConverts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the right by the number of places specified by the integer that results from the conversion of expression2.
 >>>bitwise unsigned right shiftThe same as the bitwise right shift (>> ) operator except that it does not preserve the sign of the original expression because the bits on the left are always filled with 0. Floating-point numbers are converted to integers by discarding any digits after the decimal point.
 ^bitwise XORConverts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2 , but not both, are 1.
 Bitwise compound assignment
 &=bitwise AND assignmentAssigns expression1 the value of expression1 & expression2.
 <<=bitwise left shift and assignmentThis operator performs a bitwise left shift (<<=) operation and stores the contents as a result in expression1.
 |=bitwise OR assignmentAssigns expression1 the value of expression1 | expression2.
 >>=bitwise right shift and assignmentThis operator performs a bitwise right-shift operation and stores the contents as a result in expression1.
 >>>=bitwise unsigned right shift and assignmentPerforms an unsigned bitwise right-shift operation and stores the contents as a result in expression1.
 ^=bitwise XOR assignmentAssigns expression1 the value of expression1 ^ expression2.
 Comment
 /*..*/block comment delimiterIndicates one or more lines of script comments.
 //line comment delimiterIndicates the beginning of a script comment.
 Comparison
 ==equalityTests two expressions for equality.
 eqequality (strings)Deprecated since Flash Player 5 — This operator was deprecated in favor of the == (equality) operator.
 >greater thanCompares two expressions and determines whether expression1 is greater than expression2; if it is, the operator returns true.
 gtgreater than (strings)Deprecated since Flash Player 5 — This operator was deprecated in favor of the > (greater than) operator.
 >=greater than or equal toCompares two expressions and determines whether expression1 is greater than or equal to expression2 (true) or expression1 is less than expression2 (false).
 gegreater than or equal to (strings)Deprecated since Flash Player 5 — This operator was deprecated in favor of the >= (greater than or equal to) operator.
 !=inequalityTests for the exact opposite of the equality (== ) operator.
 <>inequalityDeprecated since Flash Player 5 — This operator has been deprecated. Adobe recommends that you use the != (inequality) operator.
 <less thanCompares two expressions and determines whether expression1 is less than expression2 ; if so, the operator returns true.
 ltless than (strings)Deprecated since Flash Player 5 — This operator was deprecated in favor of the < (less than) operator.
 <=less than or equal toCompares two expressions and determines whether expression1 is less than or equal to expression2 ; if it is, the operator returns true.
 leless than or equal to (strings)Deprecated since Flash Player 5 — This operator was deprecated in Flash 5 in favor of the <= (less than or equal to) operator.
 nenot equal (strings)Deprecated since Flash Player 5 — This operator was deprecated in favor of the != (inequality) operator.
 ===strict equalityTests two expressions for equality; the strict equality (=== )operator performs in the same way as the equality (== ) operator, except that data types are not converted.
 !==strict inequalityTests for the exact opposite of the strict equality ( === ) operator.
 Logical
 &&logical ANDPerforms a Boolean operation on the values of both expressions.
 andlogical ANDDeprecated since Flash Player 5 — Adobe recommends that you use the logical AND (&&) operator.
 !logical NOTInverts the Boolean value of a variable or expression.
 notlogical NOTDeprecated since Flash Player 5 — This operator was deprecated in favor of the ! (logical NOT) operator.
 ||logical OREvaluates expression1 (the expression on the left side of the operator) and returns true if the expression evaluates to true.
 orlogical ORDeprecated since Flash Player 5 — This operator was deprecated in favor of the || (logical OR) operator.
 Other
 []array accessInitializes a new array or multidimensional array with the specified elements (a0 , and so on), or accesses elements in an array.
 ,commaEvaluates expression1 , then expression2 , and so on.
 addconcatenation (strings)Deprecated since Flash Player 5 — Adobe recommends that you use the add (+) operator when creating content for Flash Player 5 or later. This operator is not supported in Flash Player 8 or later.
 ?:conditionalInstructs Flash to evaluate expression1 , and if the value of expression1 is true , it returns the value of expression2 ; otherwise it returns the value of expression3.
 .dotUsed to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties.
  instanceofTests whether object is an instance of classConstructor or a subclass of classConstructor.
  newCreates a new, initially anonymous, object and calls the function identified by the constructor parameter.
 {}object initializerCreates a new object and initializes it with the specified name and value property pairs.
 ()parenthesesPerforms a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function outside the parentheses.
 "string delimiterWhen used before and after characters, quotation marks (") indicate that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.
 :typeUsed for strict data typing; this operator specifies the variable type, function return type, or function parameter type.
  typeofThe typeof operator evaluate the expression and returns a string specifying whether the expression is a String, MovieClip, Object, Function, Number, or Boolean value.
  voidThe void operator evaluates an expression and then discards its value, returning undefined
Operator detail
+ additionoperator
Usage
expression1 + expression2

Player version: Flash Player 4 — In Flash 4, + is only a numeric operator. In Flash Player 5 and later, + is either a numeric operator or a string concatenator depending on the data type of the parameter. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity. The following example illustrates the conversion of a Flash 4 file containing a numeric quality comparison:

Flash 4 file: x + y

Converted Flash 5 or later file: Number(x) + Number(y)

Adds numeric expressions or concatenates (combines) strings. If one expression is a string, all other expressions are converted to strings and concatenated.
If both expressions are integers, the sum is an integer; if either or both expressions are floating-point numbers, the sum is a floating-point number.

Operands
expression1 — A number or string.
expression2:Number — A number or string.

Result
Object — A string, integer, or floating-point number.

Example
Usage 1: The following example concatenates two strings and displays the result in the Output panel.
Usage 1: The following example concatenates two strings and writes the result to the log file.
var name:String = "Cola"; 
var instrument:String = "Drums"; 
trace(name + " plays " + instrument); // output: Cola plays Drums 
Usage 2: This statement adds the integers 2 and 3 and displays the resulting integer, 5, in the Output panel:
Usage 2: This statement adds the integers 2 and 3 and writes the resulting integer, 5, to the log file:
trace(2 + 3); // output: 5 
This statement adds the floating-point numbers 2.5 and 3.25 and displays the resulting floating-point number, 5.75, in the Output panel This statement adds the floating-point numbers 2.5 and 3.25 and writes the resulting floating-point number, 5.75, to the log file:
trace(2.5 + 3.25); // output: 5.75 
Usage 3: Variables associated with dynamic and input text fields have the data type String. In the following example, the variable deposit is an input text field on the Stage. After a user enters a deposit amount, the script attempts to add deposit to oldBalance. However, because deposit is a String data type, the script concatenates (combines to form one string) the variable values rather than summing them.
var oldBalance:Number = 1345.23; 
var currentBalance = deposit_txt.text + oldBalance; 
trace(currentBalance); 
For example, if a user enters 475 in the deposit text field, the trace() statement sends the value 4751345.23 to the Output panel. To correct this, use the Number() function to convert the string to a number, as in the following:
var oldBalance:Number = 1345.23; 
var currentBalance:Number = Number(deposit_txt.text) + oldBalance; 
trace(currentBalance);
The following example shows how numeric sums to the right of a string expression are not calculated:
var a:String = 3 + 10 + "asdf"; 
trace(a); // 13asdf 
var b:String = "asdf" + 3 + 10; 
trace(b); // asdf310 

+= addition assignmentoperator 
Usage
expression1 += expression2

Player version: Flash Player 4

Assigns expression1 the value of expression1+ expression2. For example, the following two statements have the same result:

x += y; 
x = x + y; 
This operator also performs string concatenation. All the rules of the addition (+) operator apply to the addition assignment (+=) operator.

Operands
expression1:Number — A number or string.
expression2:Number — A number or string.

Result
Number — The result of the addition.

Example
Usage 1: This example uses the+= operator with a string expression and sends "My name is Gilbert" to the Output panel. Usage 1: This example uses the+= operator with a string expression and writes "My name is Gilbert" to the log file.
var x1:String = "My name is "; 
x1 += "Gilbert"; 
trace(x1); // output: My name is Gilbert 
Usage 2: The following example shows a numeric use of the addition assignment (+=) operator:
var x:Number = 5; 
var y:Number = 10; 
x += y; 
trace(x); // output: 15 

See also

[] array accessoperator 
Usage
myArray = [ a0, a1,...aN ]
myArray[ i ] = value
myObject [ propertyName ]

Player version: Flash Player 4

Initializes a new array or multidimensional array with the specified elements (a0, and so on), or accesses elements in an array. The array access operator lets you dynamically set and retrieve instance, variable, and object names. It also lets you access object properties.

Usage 1: An array is an object whose properties are called elements, which are each identified by a number called an index. When you create an array, you surround the elements with the array access ([]) operator (or brackets). An array can contain elements of various types. For example, the following array, called employee, has three elements; the first is a number and the second two are strings (inside quotation marks):

var employee:Array = [15, "Barbara", "Jay"]; 
You can nest brackets to simulate multidimensional arrays. You can nest arrays up to 256 levels deep. The following code creates an array called ticTacToe with three elements; each element is also an array with three elements:
var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; 
// Select Debug > List Variables in test mode 
// to see a list of the array elements. 
Usage 2: Surround the index of each element with brackets ([]) to access it directly; you can add a new element to an array, or you can change or retrieve the value of an existing element. The first index in an array is always 0, as shown in the following example:
var my_array:Array = new Array(); 
my_array[0] = 15; 
my_array[1] = "Hello"; 
my_array[2] = true; 
You can use brackets ([]) to add a fourth element, as shown in the following example:
my_array[3] = "George"; 
You can use brackets ([]) to access an element in a multidimensional array. The first set of brackets identifies the element in the original array, and the second set identifies the element in the nested array. The following lines of code send the number 6 to the Output panel. The following line of code sends the number 6 to the log file.
var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; 
trace(ticTacToe[1][2]);// output: 6 
Usage 3: You can use the array access ([]) operator instead of the eval() function to dynamically set and retrieve values for movie clip names or any property of an object. The following line of code sends the number 6 to the Output panel. The following line of code sends the number 6 to the log file.
name["mc" + i] = "left_corner"; 

Operands
myArray:ObjectmyArray The name of an array.
a0, a1,...aN:Objecta0,a1,...aN Elements in an array; any native type or object instance, including nested arrays.
i:Numberi An integer index greater than or equal to 0.
myObject:ObjectmyObject The name of an object.
propertyName:StringpropertyName A string that names a property of the object.

Result
Object

Usage 1: A reference to an array.

Usage 2: A value from the array; either a native type or an object instance (including an Array instance).

Usage 3: A property from the object; either a native type or an object instance (including an Array instance).


Example
The following example shows two ways to create a new empty Array object; the first line uses brackets ([]):
var my_array:Array = []; 
var my_array:Array = new Array(); 

The following example creates an array called employee_array and uses the trace() statement to send the elements to the Output panel. In the fourth line, an element in the array is changed, and the fifth line sends the newly modified array to the Output panel:

The following example creates an array called employee_array and uses the trace() statement to send the elements to the log file. In the fourth line, an element in the array is changed, and the fifth line sends the newly modified array to the log file:

var employee_array = ["Barbara", "George", "Mary"]; 
trace(employee_array); // output: Barbara,George,Mary 
employee_array[2] = "Sam"; 
trace(employee_array); // output: Barbara,George,Sam 
In the following example, the expression inside the brackets ("piece" + i ) is evaluated and the result is used as the name of the variable to be retrieved from the my_mc movie clip. In this example, the variable i must live on the same Timeline as the button. If the variable i is equal to 5, for example, the value of the variable piece5 in the my_mc movie clip is displayed in the Output panel:
myBtn_btn.onRelease = function() { 
    x = my_mc["piece"+i]; 
    trace(x); 
}; 
In the following example, the expression inside the brackets is evaluated, and the result is used as the name of the variable to be retrieved from movie clip name_mc:
name_mc["A" + i]; 
If you are familiar with the Flash 4 ActionScript slash syntax, you can use the eval() function to accomplish the same result:
eval("name_mc.A" & i); 
You can use the following ActionScript to loop over all objects in the _root scope, which is useful for debugging:
for (i in _root) { 
    trace(i+": "+_root[i]); 
} 
You can also use the array access ([]) operator on the left side of an assignment statement to dynamically set instance, variable, and object names:
employee_array[2] = "Sam";

See also

= assignmentoperator 
Usage
expression1 = expression2

Player version: Flash Player 4 — In Flash 4, = is a numeric equality operator. In Flash 5 or later, = is an assignment operator, and the == operator is used to evaluate equality. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity.

Flash 4 file:
x = y

Converted Flash 5 or later file:
Number(x) == Number(y)

Assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1. Assignment can be either by value or by reference. Assignment by value copies the actual value of expression2 and stores it in expression1 . Assignment by value is used when a variable is assigned a number or string literal. Assignment by reference stores a reference to expression2 in expression1. Assignment by reference is commonly used with the new operator. Use of the new operator creates an object in memory and a reference to that location in memory is assigned to a variable.

Operands
expression1:Object — A variable, element of an array, or property of an object.
expression2:Object — A value of any type.

Result
Object — The assigned value, expression2 .

Example
The following example uses assignment by value to assign the value of 5 to the variable x.
var x:Number = 5;

The following example uses assignment by value to assign the value "hello" to the variable x:

var x:String; 
x = " hello ";

The following example uses assignment by reference to create the moonsOfJupiter variable, which contains a reference to a newly created Array object. Assignment by value is then used to copy the value "Callisto" to the first element of the array referenced by the variable moonsOfJupiter:

var moonsOfJupiter:Array = new Array(); 
moonsOfJupiter[0] = "Callisto";

The following example uses assignment by reference to create a new object, and assign a reference to that object to the variable mercury. Assignment by value is then used to assign the value of 3030 to the diameter property of the mercury object:

var mercury:Object = new Object(); mercury.diameter = 3030; // in miles 
trace (mercury.diameter); // output: 3030

The following example builds upon the previous example by creating a variable named merkur (the German word for mercury) and assigning it the value of mercury. This creates two variables that reference the same object in memory, which means you can use either variable to access the object's properties. We can then change the diameter property to use kilometers instead of miles:

var merkur:Object = mercury;
merkur.diameter = 4878; // in kilometers
trace (mercury.diameter); // output: 4878

See also

& bitwise ANDoperator 
Usage
expression1 & expression2

Player version: Flash Player 5 — In Flash 4, the AND (&) operator was used for concatenating strings. In Flash 5 and later, the AND (&) operator is a bitwise AND, and you must use the addition (+) operator to concatenate strings. Flash 4 files that use the AND (&) operator are automatically updated to use addition (+) operator when imported into the Flash 5 or later authoring environment.

Converts expression1 and expression2 to 32-bit unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.

Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted, therefore their value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value using two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and then have the most significant dig its discarded as well.

The return value is interpreted as a two's complement number with sign, so the return is an integer in the range -2147483648 to 2147483647.

Operands
expression1:Number — A number.
expression2:Number — A number.

Result
Number — The result of the bitwise operation.

Example
The following example compares the bit representation of the numbers and returns 1 only if both bits at the same position are 1. In this ActionScript, you add 13 (binary 1101) and 11 (binary 1011) and return 1 only in the position where both numbers have a 1.
var insert:Number = 13; 
var update:Number = 11; 
trace(insert & update); // output : 9 (or 1001 binary) 
In the numbers 13 and 11 the result is 9 because only the first and last positions in both numbers have the number 1.

The following examples show the behavior of the return value conversion:

trace(0xFFFFFFFF); // 4294967295 
trace(0xFFFFFFFF & 0xFFFFFFFF); // -1 
trace(0xFFFFFFFF & -1); // -1 
trace(4294967295 & -1); // -1 
trace(4294967295 & 4294967295); // -1 

See also

&= bitwise AND assignmentoperator 
Usage
expression1 &= expression2

Player version: Flash Player 5

Assigns expression1 the value of expression1 & expression2. For example, the following two expressions are equivalent:

x &= y; 
x = x & y; 

Operands
expression1:Number — A number.
expression2:Number — A number.

Result
Number — The value of expression1 & expression2 .

Example
The following example assigns the value 9 to x:
var x:Number = 15; 
var y:Number = 9; 
trace(x &= y); // output: 9 

See also

<< bitwise left shiftoperator 
Usage
expression1 << expression2

Player version: Flash Player 5

Converts expression1 and expression2 to 32-bit integer values; you can call them V1 and V2. Shifts all bits of the value of V1 to the left by V2 positions. Discards bits shifted off the left end of V1 by this operation, and inserts zeros in the bit positions on the right that are emptied. Shifting a value left by one position is the equivalent of multiplying it by 2.

Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and also have the most significant digits discarded.

The return value is interpreted as a two's complement number with sign, so the return value will be an integer in the range -2147483648 to 2147483647.

Operands
expression1:Number — A number or expression to be shifted left.
expression2:Number — A number or expression that converts to an integer from 0 to 31.

Result
Number — The result of the bitwise operation.

Example
In the following example, the integer 1 is shifted 10 bits to the left: x = 1 << 10 The result of this operation is x = 1024. This is because 1 decimal equals 1 binary, 1 binary shifted left by 10 is 10000000000 binary, and 10000000000 binary is 1024 decimal. In the following example, the integer 7 is shifted 8 bits to the left: x = 7 << 8 The result of this operation is x = 1792. This is because 7 decimal equals 111 binary, 111 binary shifted left by 8 bits is 11100000000 binary, and 11100000000 binary is 1792 decimal. If you trace the following example, you see that the bits have been pushed two spaces to the left:
// 2 binary == 0010 
// 8 binary == 1000 
trace(2 << 2); // output: 8 

See also

<<= bitwise left shift and assignmentoperator 
Usage
expression1 <<= expression2

Player version: Flash Player 5

This operator performs a bitwise left shift (<<=) operation and stores the contents as a result in expression1. The following two expressions are equivalent:

A <<= B; 
A = (A << B)

Operands
expression1:Number — A number or expression to be shifted left.
expression2:Number — A number or expression that converts to an integer from 0 to 31.

Result
Number — The result of the bitwise operation.

Example
In the following example, you use the bitwise left shift and assignment (<<=) operator to shift all bits one space to the left:
var x:Number = 4; 
// shift all bits one slot to the left. 
x <<= 1; 
trace(x); // output: 8 
// 4 decimal = 0100 binary 
// 8 decimal = 1000 binary 

See also

~ bitwise NOToperator 
Usage
~expression

Player version: Flash Player 5

Also known as the one's complement operator or the bitwise complement operator. Converts the expression to a 32-bit signed integer, and then applies a bitwise one's complement. That is, every bit that is a 0 is set to 1 in the result, and every bit that is a 1 is set to 0 in the result. The result is a signed 32-bit integer.

For example, the hexadecimal value 0x7777 is represented as this binary number:
0111011101110111

The bitwise negation of that hexadecimal value, ~0x7777, is this binary number:
1000100010001000

In hexadecimal, this is 0x8888. Therefore, ~0x7777 is 0x8888.

The most common use of bitwise operators is for representing flag bits (Boolean values packed into 1 bit each).

Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and also have the most significant digits discarded.

The return value is interpreted as a two's complement number with sign, so the return value is an integer in the range -2147483648 to 2147483647.

Operands
expression:Number — A number.

Result
Number — The result of the bitwise operation.

Example
The following example demonstrates a use of the bitwise NOT (-) operator with flag bits:
var ReadOnlyFlag:Number = 0x0001; // defines bit 0 as the read-only flag 
var flags:Number = 0; 
trace(flags); 
/* To set the read-only flag in the flags variable, 
   the following code uses the bitwise OR: 
*/
flags |= ReadOnlyFlag; 
trace(flags); 
/* To clear the read-only flag in the flags variable, 
   first construct a mask by using bitwise NOT on ReadOnlyFlag. 
   In the mask, every bit is a 1 except for the read-only flag. 
   Then, use bitwise AND with the mask to clear the read-only flag. 
   The following code constructs the mask and performs the bitwise AND: 
*/ 
flags &= ~ReadOnlyFlag; 
trace(flags); 
// output: 0 1 0 

See also

| bitwise ORoperator 
Usage
expression1 | expression2

Player version: Flash Player 5

Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.

Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and also have the most significant digits discarded.

The return value is interpreted as a two's complement number with sign, so the return value will be an integer in the range -2147483648 to 2147483647.

Operands
expression1:Number — A number.
expression2:Number — A number.

Result
Number — The result of the bitwise operation.

Example
The following is an example of a bitwise OR (|) operation:
// 15 decimal = 1111 binary 
var x:Number = 15; 
// 9 decimal = 1001 binary 
var y:Number = 9; 
// 1111 | 1001 = 1111 
trace(x | y); // returns 15 decimal (1111 binary) 
Don't confuse the single | (bitwise OR) with || (logical OR).

See also

|= bitwise OR assignmentoperator 
Usage
expression1 |= expression2

Player version: Flash Player 5

Assigns expression1 the value of expression1 | expression2. For example, the following two statements are equivalent:

x |= y;
x = x | y; 

Operands
expression1:Number — A number or variable.
expression2:Number — A number or variable.

Result
Number — The result of the bitwise operation.

Example
The following example uses the bitwise OR assignment (|=) operator:
// 15 decimal = 1111 binary 
var x:Number = 15; 
// 9 decimal = 1001 binary 
var y:Number = 9; 
// 1111 |= 1001 = 1111 
trace(x |= y); // returns 15 decimal (1111 binary) 

See also

>> bitwise right shiftoperator 
Usage
expression1 >> expression2

Player version: Flash Player 5

Converts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the right by the number of places specified by the integer that results from the conversion of expression2 . Bits that are shifted off the right end are discarded. To preserve the sign of the original expression , the bits on the left are filled in with 0 if the most significant bit (the bit farthest to the left) of expression1 is 0, and filled in with 1 if the most significant bit is 1. Shifting a value right by one position is the equivalent of dividing by 2 and discarding the remainder.

Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and also have the most significant digits discarded.

The return value is interpreted as a two's complement number with sign, so the return value will be an integer in the range -2147483648 to 2147483647.

Operands
expression1:Number — A number or expression to be shifted right.
expression2:Number — A number or expression that converts to an integer from 0 to 31.

Result
Number — The result of the bitwise operation.

Example
The following example converts 65535 to a 32-bit integer and shifts it 8 bits to the right:
var x:Number = 65535 >> 8; 
trace(x); // outputs 255
The following example shows the result of the previous example:
var x:Number = 255;
This is because 65535 decimal equals 1111111111111111 binary (sixteen 1s), 1111111111111111 binary shifted right by 8 bits is 11111111 binary, and 11111111 binary is 255 decimal. The most significant bit is 0 because the integers are 32-bit, so the fill bit is 0.

The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right:

var x:Number = -1 >> 1;
trace(x); // outputs -1
The following example shows the result of the previous example:
var x:Number = -1;
This is because -1 decimal equals 11111111111111111111111111111111 binary (thirty-two 1s), shifting right by one bit causes the least significant (bit farthest to the right) to be discarded and the most significant bit to be filled in with 1. The result is 11111111111111111111111111111111 (thirty-two 1s) binary, which represents the 32-bit integer -1.

See also

>>= bitwise right shift and assignmentoperator 
Usage
expression1 >>= expression2

Player version: Flash Player 5

This operator performs a bitwise right-shift operation and stores the contents as a result in expression1.

The following two statements are equivalent:

A >>= B;  
A = (A >> B);

Operands
expression1:Number — A number or expression to be shifted right.
expression2:Number — A number or expression that converts to an integer from 0 to 31.

Result
Number — The result of the bitwise operation.

Example
The following commented code uses the bitwise right shift and assignment (>>=) operator.
function convertToBinary(numberToConvert:Number):String { 
    var result:String = ""; 
    for (var i = 0; i<32; i++) { 
        // Extract least significant bit using bitwise AND 
        var lsb:Number = numberToConvert & 1; 
        // Add this bit to the result 
        string result = (lsb ? "1" : "0")+result; 
        // Shift numberToConvert right by one bit, to see next bit 
        numberToConvert >>= 1; 
    } 
    return result; 
} 
trace(convertToBinary(479)); 
// Returns the string 00000000000000000000000111011111 
// This string is the binary representation of the decimal 
// number 479

See also

>>> bitwise unsigned right shiftoperator 
Usage
expression1 >>> expression2

Player version: Flash Player 5

The same as the bitwise right shift (>>) operator except that it does not preserve the sign of the original expression because the bits on the left are always filled with 0.

Floating-point numbers are converted to integers by discarding any digits after the decimal point. Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and also have the most significant digits discarded.

Operands
expression1:Number — A number or expression to be shifted right.
expression2:Number — A number or expression that converts to an integer between 0 and 31.

Result
Number — The result of the bitwise operation.

Example
The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right:
var x:Number = -1 >>> 1; 
trace(x); // output: 2147483647 

This is because -1 decimal is 11111111111111111111111111111111 binary (thirty-two 1s), and when you shift right (unsigned) by 1 bit, the least significant (rightmost) bit is discarded, and the most significant (leftmost) bit is filled with a 0. The result is 01111111111111111111111111111111 binary, which represents the 32-bit integer 2147483647.

See also

>>>= bitwise unsigned right shift and assignmentoperator 
Usage
expression1 >>>= expression2

Player version: Flash Player 5

Performs an unsigned bitwise right-shift operation and stores the contents as a result in expression1. The following two statements are equivalent:

A >>>= B; 
A = (A >>> B); 

Operands
expression1:Number — A number or expression to be shifted right.
expression2:Number — A number or expression that converts to an integer from 0 to 31.

Result
Number — The result of the bitwise operation.

Example

See also

^ bitwise XORoperator 
Usage
expression1 ^ expression2

Player version: Flash Player 5

Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2, but not both, are 1. Floating-point numbers are converted to integers by discarding any digits after the decimal point. The result is a new 32-bit integer.

Positive integers are converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; values larger than the maximum have their most significant digits discarded when they are converted so the value is still 32-bit. Negative numbers are converted to an unsigned hexadecimal value via the two's complement notation, with the minimum being -2147483648 or 0x800000000; numbers less than the minimum are converted to two's complement with greater precision and also have the most significant digits discarded.

The return value is interpreted as a two's complement number with sign, so the return value will be an integer in the range -2147483648 to 2147483647.

Operands
expression1:Number — A number.
expression2:Number — A number.

Result
Number — The result of the bitwise operation.

Example
The following example uses the bitwise XOR operator on the decimals 15 and 9, and assigns the result to the variable x:
// 15 decimal = 1111 binary 
// 9 decimal = 1001 binary 
var x:Number = 15 ^ 9; 
trace(x); 
// 1111 ^ 1001 = 0110 
// returns 6 decimal (0110 binary) 

See also

^= bitwise XOR assignmentoperator 
Usage
expression1 ^= expression2

Player version: Flash Player 5

Assigns expression1 the value of expression1 ^ expression2. For example, the following two statements are equivalent:

x ^= y; 
x = x ^ y; 

Operands
expression1:Number — Integers and variables.
expression2:Number — Integers and variables.

Result
Number — The result of the bitwise operation.

Example
The following example shows a bitwise XOR assignment (^=) operation:
// 15 decimal = 1111 binary 
var x:Number = 15; 
// 9 decimal = 1001 binary 
var y:Number = 9; 
trace(x ^= y); // returns 6 decimal (0110 binary) 

See also

/*..*/ block comment delimiteroperator 
Usage
/* comment */
/* comment
   comment */

Player version: Flash Player 5

Indicates one or more lines of script comments. Any characters that appear between the opening comment tag (/*) and the closing comment tag (*/), are interpreted as a comment and ignored by the ActionScript interpreter. Use the // (comment delimiter) to identify single-line comments. Use the /* comment delimiter to identify comments on multiple successive lines. Leaving off the closing tag (*/) when using this form of comment delimiter returns an error message. Attempting to nest comments also returns an error message. After an opening comment tag (/*) is used, the first closing comment tag (*/) will end the comment, regardless of the number of opening comment tags (/*) placed between them.

Operands
comment — Any characters.

Example
The following script uses comment delimiters at the beginning of the script:
/* records the X and Y positions of 
the ball and bat movie clips */ 
var ballX:Number = ball_mc._x; 
var ballY:Number = ball_mc._y; 
var batX:Number = bat_mc._x; 
var batY:Number = bat_mc._y; 
The following attempt to nest comments will result in an error message:
/* this is an attempt to nest comments. 
/* But the first closing tag will be paired 
with the first opening tag */ 
and this text will not be interpreted as a comment */ 

See also

, commaoperator 
Usage
(expression1 , expression2 [, expressionN... ])

Player version: Flash Player 4

Evaluates expression1, then expression2, and so on. This operator is primarily used with the for loop statement and is often used with the parentheses () operator.

Operands
expression1:Number — An expression to be evaluated.
expression2:Number — An expression to be evaluated.
expressionN:Number — Any number of additional expressions to be evaluated.

Result
Object — The value of expression1, expression2, and so on.

Example
The following example uses the comma (,) operator in a for loop:
for (i = 0, j = 0; i < 3 && j < 3; i++, j+=2) { 
    trace("i = " + i + ", j = " + j); 
} 
// Output: 
// i = 0, j = 0 
// i = 1, j = 2
The following example uses the comma (,) operator without the parentheses () operator to show that the comma operator is of lower precedence than assignment (=) operator:
var v:Number = 0; 
v = 4, 5, 6; 
trace(v); // output: 4 
The following example uses the comma (,) operator with the parentheses () operator and illustrates that the comma operator returns the value of the last expression:
var v:Number = 0; 
v = (4, 5, 6); 
trace(v); // output: 6 
The following example uses the comma (,) operator without the parentheses () operator and illustrates that the comma operator sequentially evaluates all of the expressions. The first expression, v + 4 is assigned to the variable v because the assignment (=) operator is of higher precedence than the comma operator. The second expression, z++, is evaluated and z is incremented by one.
var v:Number = 0; 
var z:Number = 0; 
v = v + 4 , z++, v + 6; 
trace(v); // output: 4 
trace(z); // output: 1 
The following example is identical to the previous example except for the addition of the parentheses () operator, which changes the order of operations such that the comma operator is evaluated before the assignment (=) operator:
var v:Number = 0; 
var z:Number = 0; 
v = (v + 4, z++, v + 6); 
trace(v); // output: 6 
trace(z); // output: 1 

See also

add concatenation (strings)operator 

Deprecated since Flash Player 5 — Adobe recommends that you use the add (+) operator when creating content for Flash Player 5 or later. This operator is not supported in Flash Player 8 or later.

Usage
string1 add string2

Player version: Flash Player 4

Concatenates two or more strings. The add (+) operator replaces the Flash 4 & operator; Flash Player 4 files that use the & operator are automatically converted to use the add (+) operator for string concatenation when brought into the Flash 5 or later authoring environment. Use the add (+) operator to concatenate strings if you are creating content for Flash Player 4 or earlier versions of the Player.

Operands
string1:String — A string.
string2:String — A string.

Result
String — The concatenated string.

See also

?: conditionaloperator 
Usage
expression1 ? expression2 : expression3

Player version: Flash Player 4

Instructs Flash to evaluate expression1, and if the value of expression1 is true, it returns the value of expression2; otherwise it returns the value of expression3.

Operands
expression1:Object — An expression that evaluates to a Boolean value; usually a comparison expression, such as x < 5.
expression2:Object — Values of any type.
expression3:Object — Values of any type.

Result
Object — The value of expression2 or expression3.

Example
The following statement assigns the value of variable x to variable z because expression1 evaluates to true:
var x:Number = 5; 
var y:Number = 10; 
var z = (x < 6) ? x: y; 
trace (z); // returns 5
The following example shows a conditional statement written in shorthand:
var timecode:String = (new Date().getHours() < 11) ? "AM" : "PM"; 
trace(timecode); 
The same conditional statement could also be written in longhand, as shown in the following example:
if (new Date().getHours() < 11) { 
    var timecode:String = "AM"; 
} else { 
    var timecode:String = "PM"; 
} trace(timecode); 

-- decrementoperator 
Usage
--expression
expression--

Player version: Flash Player 4

A pre-decrement and post-decrement unary operator that subtracts 1 from the expression . The expression can be a variable, element in an array, or property of an object. The pre-decrement form of the operator (--expression) subtracts 1 from expression and returns the result. The post-decrement form of the operator (expression--) subtracts 1 from the expression and returns the initial value of expression (the value prior to the subtraction).

Operands
expression:Number — A number or a variable that evaluates to a number.

Result
Number — The result of the decremented value.

Example
The pre-decrement form of the operator decrements x to 2 ( x - 1 = 2) and returns the result as y:
var x:Number = 3; 
var y:Number = --x; //y is equal to 2
The post-decrement form of the operator decrements x to 2 (x - 1 = 2 ) and returns the original value of x as the result y:
var x:Number = 3; 
var y:Number = x--; //y is equal to 3
The following example loops from 10 to 1, and each iteration of the loop decreases the counter variable i by 1.
for (var i = 10; i>0; i--) { 
    trace(i); 
}

/ divisionoperator 
Usage
expression1 / expression2

Player version: Flash Player 4

Divides expression1 by expression2. The result of the division operation is a double-precision floating-point number.

Operands
expression:Number — A number or a variable that evaluates to a number.

Result
Number — The floating-point result of the operation.

Example
The following statement divides the current width and height of the Stage, and then displays the result in the Output panel. The following statement divides the current width and height of the Stage and then writes the result to the log file.
trace(Stage.width/2); 
trace(Stage.height/2); 
For a default Stage width and height of 550 x 400, the output is 275 and 150.

See also

/= division assignmentoperator 
Usage
expression1 /= expression2

Player version: Flash Player 4

Assigns expression1 the value of expression1 / expression2. For example, the following two statements are equivalent:

x /= y;
x = x / y;

Operands
expression1:Number — A number or a variable that evaluates to a number.
expression2:Number — A number or a variable that evaluates to a number.

Result
Number — A number.

Example
The following code illustrates using the division assignment (/=) operator with variables and numbers:
var x:Number = 10; 
var y:Number = 2; 
x /= y; trace(x); // output: 5 

See also

. dotoperator 
Usage
object.property_or_method
instancename.variable
instancename.childinstance
instancename.childinstance.variable

Player version: Flash Player 4

Used to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties. The dot operator is also used to test or set the properties of an object or top-level class, execute a method of an object or top-level class, or create a data structure.

Operands
object:Object — An instance of a class. The object can be an instance of any of the built-in ActionScript classes or a custom class. This parameter is always to the left of the dot (.) operator.
property_or_method — The name of a property or method associated with an object. All the valid methods and properties for the built-in classes are listed in the method and property summary tables for that class. This parameter is always to the right of the dot (.) operator.
instancename:MovieClip — The instance name of a movie clip.
variable — The instance name to the left of the dot (.) operator can also represent a variable on the Timeline of the movie clip.
childinstance:MovieClip — A movie clip instance that is a child of, or nested in, another movie clip.

Result
Object — The method, property or movie clip named on the right side of the dot.

Example
The following example identifies the current value of the variable hairColor in the movie clip person_mc:
person_mc.hairColor 
The Flash 4 authoring environment did not support dot syntax, but Flash MX 2004 files published for Flash Player 4 can use the dot operator. The preceding example is equivalent to the following (deprecated) Flash 4 syntax:
/person_mc:hairColor 
The following example creates a new movie clip within the _root scope. Then a text field is created inside the movie clip called container_mc. The text field's autoSize property is set to true and then populated with the current date.
this.createEmptyMovieClip("container_mc", this.getNextHighestDepth()); 
this.container_mc.createTextField("date_txt", this.getNextHighestDepth(), 0, 0, 100, 22); 
this.container_mc.date_txt.autoSize = true; 
this.container_mc.date_txt.text = new Date(); 
The dot (.) operator is used when targeting instances within the SWF file and when you need to set properties and values for those instances.

== equalityoperator 
Usage
expression1 == expression2

Player version: Flash Player 5

Tests two expressions for equality. The result is true if the expressions are equal.

The definition of equal depends on the data type of the parameter:

When comparing by value, if expression1 and expression2 are different data types, ActionScript will attempt to convert the data type of expression2 to match that of expression1.

Operands
expression1:Object — A number, string, Boolean value, variable, object, array, or function.
expression2:Object — A number, string, Boolean value, variable, object, array, or function.

Result
Boolean — The Boolean result of the comparison.

Example
The following example uses the equality (==) operator with an if statement:
var a:String = "David", b:String = "David"; 
if (a == b) { 
    trace("David is David"); 
} 
The following examples show the results of operations that compare mixed types:
var x:Number = 5; 
var y:String = "5"; 
trace(x == y); // output: true 
var x:String = "5"; 
var y:String = "66"; 
trace(x == y); // output: false 
var x:String = "chris"; 
var y:String = "steve"; 
trace(x == y); // output: false 
The following examples show comparison by reference. The first example compares two arrays with identical length and elements. The equality operator will return false for these two arrays. Although the arrays appear equal, comparison by reference requires that they both refer to the same array. The second example creates the thirdArray variable, which points to the same array as the variable firstArray. The equality operator will return true for these two arrays because the two variables refer to the same array.
var firstArray:Array = new Array("one", "two", "three"); 
var secondArray:Array = new Array("one", "two", "three"); 
trace(firstArray == secondArray); 
// will output false 
// Arrays are only considered equal 
// if the variables refer to the same array. 
var thirdArray:Array = firstArray; 
trace(firstArray == thirdArray); // will output true 

See also

eq equality (strings)operator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the == (equality) operator.

Usage
expression1 eq expression2

Player version: Flash Player 4

Compares two expressions for equality and returns a value of true if the string representation of expression1 is equal to the string representation of expression2, false otherwise.

Operands
expression1:Object — Numbers, strings, or variables.
expression2:Object — Numbers, strings, or variables.

Result
Boolean — The result of the comparison.

See also

> greater thanoperator 
Usage
expression1 > expression2

Player version: Flash Player 4 — In Flash 4, > is a numeric operator. In Flash 5 or later, the greater-than (>) operator is a comparison operator capable of handling various data types. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison. Flash 4 file: x > y Converted Flash 5 or later file: Number(x) > Number(y)

Compares two expressions and determines whether expression1 is greater than expression2; if it is, the operator returns true. If expression1 is less than or equal to expression2, the operator returns false. String expressions are evaluated using alphabetical order; all capital letters come before lowercase letters.

Operands
expression1:Object — A number or string.
expression2:Object — A number or string.

Result
Boolean — The Boolean result of the comparison.

Example
In the following example, the greater than (>) operator is used to determine whether the value of the text field score_txt is greater than 90:
if (score_txt.text>90) { 
    trace("Congratulations, you win!"); 
} else { 
    trace("sorry, try again"); 
} 

gt greater than (strings)operator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the > (greater than) operator.

Usage
expression1 gt expression2

Player version: Flash Player 4

Compares the string representation of expression1 with the string representation of expression2 and returns true if expression1 is greater than expression2, false otherwise.

Operands
expression1:Object — Numbers, strings, or variables.
expression2:Object — Numbers, strings, or variables.

Result
Boolean — The Boolean result of the comparison.

See also

>= greater than or equal tooperator 
Usage
expression1 >= expression2

Player version: Flash Player 4 — In Flash 4, >= is a numeric operator. In Flash 5 or later, the greater than or equal to (>=) operator is a comparison operator capable of handling various data types. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison. Flash 4 file: x >= y Converted Flash 5 or later file: Number(x) >= Number(y)

Compares two expressions and determines whether expression1 is greater than or equal to expression2 (true) or expression1 is less than expression2 (false).

Operands
expression1:Object — A string, integer, or floating-point number.
expression2:Object — A string, integer, or floating-point number.

Result
Boolean — The Boolean result of the comparison.

Example
In the following example, the greater than or equal to (>=) operator is used to determine whether the current hour is greater than or equal to 12:
if (new Date().getHours() >= 12) { 
    trace("good afternoon"); 
} else { 
    trace("good morning"); 
}

ge greater than or equal to (strings)operator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the >= (greater than or equal to) operator.

Usage
expression1 ge expression2

Player version: Flash Player 4

Compares the string representation of expression1 with the string representation of expression2 and returns true if expression1 is greater than or equal to expression2, false otherwise.

Operands
expression1:Object — Numbers, strings, or variables.
expression2:Object — Numbers, strings, or variables.

Result
Boolean — The result of the comparison.

See also

++ incrementoperator 
Usage
++expression
expression++

Player version: Flash Player 4

A pre-increment and post-increment unary operator that adds 1 to expression . The expression can be a variable, element in an array, or property of an object. The pre-increment form of the operator (++expression) adds 1 to expression and returns the result. The post-increment form of the operator (expression++ ) adds 1 to expression and returns the initial value of expression (the value prior to the addition).

The pre-increment form of the operator increments x to 2 (x + 1 = 2) and returns the result as y:

var x:Number = 1; 
var y:Number = ++x; 
trace("x:"+x); //traces x:2 
trace("y:"+y); //traces y:2
The post-increment form of the operator increments x to 2 (x + 1 = 2) and returns the original value of x as the result y:
var x:Number = 1; 
var y:Number = x++; 
trace("x:"+x); //traces x:2 
trace("y:"+y); //traces y:1

Operands
expression:Number — A number or a variable that evaluates to a number.

Result
Number — The result of the increment.

Example
The following example uses ++ as a post-increment operator to make a while loop run five times:
var i:Number = 0; 
while (i++ < 5) { 
    trace("this is execution " + i); 
} 
/* output: 
   this is execution 1 
   this is execution 2 
   this is execution 3 
   this is execution 4 
   this is execution 5 
*/
The following example uses ++ as a pre-increment operator:
var a:Array = new Array(); 
var i:Number = 0; 
while (i < 10) { 
    a.push(++i); 
} 
trace(a.toString()); //traces: 1,2,3,4,5,6,7,8,9,10 
This example also uses ++ as a pre-increment operator.
var a:Array = []; 
for (var i = 1; i <= 10; ++i) { 
    a.push(i); 
} 
trace(a.toString()); //traces: 1,2,3,4,5,6,7,8,9,10 
This script shows the following result in the Output panel: This script writes the following result to the log file: 1,2,3,4,5,6,7,8,9,10 The following example uses ++ as a post-increment operator in a while loop:
// using a while loop 
var a:Array = new Array(); 
var i:Number = 0; 
while (i < 10) { 
    a.push(i++); 
} 
trace(a.toString()); //traces 0,1,2,3,4,5,6,7,8,9 
The following example uses ++ as a post-increment operator in a for loop:
// using a for loop 
var a:Array = new Array(); 
for (var i = 0; i < 10; i++) { 
    a.push(i); 
} 
trace(a.toString()); //traces 0,1,2,3,4,5,6,7,8,9 
This script displays the following result in the Output panel: This script writes the following result to the log file:
0,1,2,3,4,5,6,7,8,9 

!= inequalityoperator 
Usage
expression1 != expression2

Player version: Flash Player 5

Tests for the exact opposite of the equality ( ==) operator. If expression1 is equal to expression2 , the result is false. As with the equality (==) operator, the definition of equal depends on the data types being compared, as illustrated in the following list:

Comparison by value means what most people would expect equals to mean--that two expressions have the same value. For example, the expression (2 + 3) is equal to the expression (1 + 4) when compared by value.

Comparison by reference means that two expressions are equal only if they both refer to the same object, array, or function. Values inside the object, array, or function are not compared.

When comparing by value, if expression1 and expression2 are different data types, ActionScript will attempt to convert the data type of expression2 to match that of expression1.

Operands
expression1:Object — A number, string, Boolean value, variable, object, array, or function.
expression2:Object — A number, string, Boolean value, variable, object, array, or function.

Result
Boolean — The Boolean result of the comparison.

Example
The following example illustrates the result of the inequality (!=) operator:
trace(5 != 8); // returns true 
trace(5 != 5) //returns false 
The following example illustrates the use of the inequality (!=) operator in an if statement:
var a:String = "David";
var b:String = "Fool";
if (a != b) { 
    trace("David is not a fool"); 
}
The following example illustrates comparison by reference with two functions:
var a:Function = function() { trace("foo"); }; 
var b:Function = function() { trace("foo"); }; 
a(); // foo 
b(); // foo 
trace(a != b); // true 
a = b; 
a(); // foo 
b(); // foo 
trace(a != b); // false 
// trace statement output: foo foo true foo foo false 
The following example illustrates comparison by reference with two arrays:
var a:Array = [ 1, 2, 3 ]; 
var b:Array = [ 1, 2, 3 ]; 
trace(a); // 1, 2, 3 
trace(b); // 1, 2, 3 
trace(a!=b); // true 
a = b; 
trace(a); // 1, 2, 3 
trace(b); // 1, 2, 3 
trace(a != b); // false 
// trace statement output: 1,2,3 1,2,3 true 1,2,3 1,2,3 false 

See also

<> inequalityoperator 

Deprecated since Flash Player 5 — This operator has been deprecated. Adobe recommends that you use the != (inequality) operator.

Usage
expression1 <> expression2

Player version: Flash Player 2

Tests for the exact opposite of the equality (==) operator. If expression1 is equal to expression2, the result is false. As with the equality (==) operator, the definition of equal depends on the data types being compared:

Operands
expression1:Object — A number, string, Boolean value, variable, object, array, or function.
expression2:Object — A number, string, Boolean value, variable, object, array, or function.

Result
Boolean — The Boolean result of the comparison.

See also

instanceofoperator 
Usage
object instanceof classConstructor

Player version: Flash Player 6

Tests whether object is an instance of classConstructor or a subclass of classConstructor. The instanceof operator does not convert primitive types to wrapper objects. For example, the following code returns true:

new String("Hello") instanceof String;
Whereas the following code returns false:
"Hello" instanceof String;

Operands
object:Object — An ActionScript object.
classConstructor:Function — A reference to an ActionScript constructor function, such as String or Date.

Result
Boolean — If object is an instance of or a subclass of classConstructor, instanceof returns true, otherwise it returns false. Also, _global instanceof Object returns false.

See also

< less thanoperator 
Usage
expression1 < expression2

Player version: Flash Player 4 — In Flash 4, < is a numeric operator. In Flash 5 and later, the < (less than) operator is a comparison operator capable of handling various data types. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison.

Flash 4 file: x < y

Converted Flash 5 or later file: Number(x) < Number(y)

Compares two expressions and determines whether expression1 is less than expression2; if so, the operator returns true. If expression1 is greater than or equal to expression2, the operator returns false. String expressions are evaluated using alphabetical order; all capital letters come before lowercase letters.

Operands
expression1:Number — A number or string.
expression2:Number — A number or string.

Result
Boolean — The Boolean result of the comparison.

Example
The following examples show true and false returns for both numeric and string comparisons:
trace(3 < 10); // true 
trace(10 < 3); // false 
trace("Allen" < "Jack"); // true 
trace("Jack" < "Allen"); //false 
trace("11" < "3"); // true 
trace("11" < 3); // false (numeric comparison) 
trace("C" < "abc"); // true 
trace("A" < "a"); // true 

lt less than (strings)operator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the < (less than) operator.

Usage
expression1 lt expression2

Player version: Flash Player 4

Compares expression1 to expression2 and returns true if expression1 is less than expression2, false otherwise.

Operands
expression1:Object — Numbers, strings, or variables.
expression2:Object — Numbers, strings, or variables.

Result
Boolean — The result of the comparison.

See also

<= less than or equal tooperator 
Usage
expression1 <= expression2

Player version: Flash Player 4 — In Flash 4, <= is a numeric operator. In Flash 5 or later, the less than or equal to (<= ) operator is a comparison operator capable of handling various data types. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a conversion process to maintain data type integrity. The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison.

Flash 4 file: x <= y

Converted Flash 5 or later file: Number(x) <= Number(y)

Compares two expressions and determines whether expression1 is less than or equal to expression2; if it is, the operator returns true. If expression1 is greater than expression2, the operator returns false. String expressions are evaluated using alphabetical order; all capital letters come before lowercase letters.

Operands
expression1:Object — A number or string.
expression2:Object — A number or string.

Result
Boolean — The Boolean result of the comparison.

Example
The following examples show true and false results for both numeric and string comparisons:
trace(5 <= 10); // true 
trace(2 <= 2); // true 
trace(10 <= 3); // false 
trace("Allen" <= "Jack"); // true 
trace("Jack" <= "Allen"); // false 
trace("11" <= "3"); // true 
trace("11" <= 3); // false (numeric comparison) 
trace("C" <= "abc"); // true 
trace("A" <= a); // true 

le less than or equal to (strings)operator 

Deprecated since Flash Player 5 — This operator was deprecated in Flash 5 in favor of the <= (less than or equal to) operator.

Usage
expression1 le expression2

Player version: Flash Player 4

Compares expression1 to expression2 and returns a value of true if expression1 is less than or equal to expression2, false otherwise.

Operands
expression1:Object — Numbers, strings, or variables.
expression2:Object — Numbers, strings, or variables.

Result
Boolean — The result of the comparison.

See also

// line comment delimiteroperator 
Usage
// comment

Player version: Flash Player 1.0

Indicates the beginning of a script comment. Any characters that appear between the comment delimiter (//) and the end-of-line character are interpreted as a comment and ignored by the ActionScript interpreter.

Operands
comment — Any characters.

Example
The following script uses comment delimiters to identify the first, third, fifth, and seventh lines as comments:
// record the X position of the ball movie clip 
var ballX:Number = ball_mc._x; 
// record the Y position of the ball movie clip 
var ballY:Number = ball_mc._y; 
// record the X position of the bat movie clip 
var batX:Number = bat_mc._x; 
// record the Y position of the bat movie clip 
var batY:Number = bat_mc._y; 

See also

&& logical ANDoperator 
Usage
expression1 && expression2

Player version: Flash Player 4

Performs a Boolean operation on the values of both expressions. If expression1 and expression2 are both true, then true is returned; otherwise, false is returned.

Expression Evaluates
true&&true true
true&&false false
false&&false false
false&&true false

Operands
expression1:Number — A Boolean value or an expression that converts to a Boolean value.
expression2:Number — A Boolean value or an expression that converts to a Boolean value.

Result
Object — A Boolean value if both operands are members of the Boolean data type. Otherwise, the result will be the value of either expression.

Example
The following example uses the logical AND (&&) operator to perform a test to determine if a player has won the game. The turns variable and the score variable are updated when a player takes a turn or scores points during the game. The script shows "You Win the Game!" in the Output panel when the player's score reaches 75 or higher in 3 turns or less. The script writes "You Win the Game!" to the log file when the player's score reaches 75 or higher in 3 turns or less.
var turns:Number = 2; 
var score:Number = 77; 
if ((turns <= 3) && (score >= 75)) { 
    trace("You Win the Game!"); 
} else { 
    trace("Try Again!"); 
} 
// output: You Win the Game! 

See also

and logical ANDoperator 

Deprecated since Flash Player 5 — Adobe recommends that you use the logical AND (&&) operator.

Usage
condition1 and condition2

Player version: Flash Player 4

Performs a logical AND (&&) operation in Flash Player 4. If both expressions evaluate to true, the entire expression is true.

Operands
condition1:Boolean — Conditions or expressions that evaluate to true or false.
condition2:Boolean — Conditions or expressions that evaluate to true or false.

Result
Boolean — A Boolean result of the logical operation.

See also

! logical NOToperator 
Usage
! expression

Player version: Flash Player 4

Inverts the Boolean value of a variable or expression. If expression is a variable with the absolute or converted value true, the value of ! expression is false. If the expression x && y evaluates to false, the expression !(x && y) evaluates to true.

The following expressions illustrate the result of using the logical NOT (!) operator:

! true returns false
! false returns true

Operands
expression:Boolean — An expression or a variable that evaluates to a Boolean value.

Result
Boolean — The Boolean result of the logical operation.

Example
In the following example, the variable happy is set to false. The if condition evaluates the condition !happy, and if the condition is true, the trace() statement sends a string to the Output panel. The if condition evaluates the condition !happy, and if the condition is true, the trace() statement sends a string to the log file.
var happy:Boolean = false; 
if (!happy) { 
    trace("don't worry, be happy"); //traces don't worry, be happy 
} 
The statement traces because !false equals true.

See also

not logical NOToperator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the ! (logical NOT) operator.

Usage
not expression

Player version: Flash Player 4

Performs a logical NOT (!) operation in Flash Player 4.

Operands
expression:Object — A variable or other expression that converts to a Boolean value.

Result
Boolean — The result of the logical operation.

See also

|| logical ORoperator 
Usage
expression1 || expression2

Player version: Flash Player 4

Evaluates expression1 (the expression on the left side of the operator) and returns true if the expression evaluates to true. If expression1 evaluates to false, expression2 (the expression on the right side of the operator) is evaluated. If expression2 evaluates to false, the final result is false; otherwise, it is true.

If you use a function call as expression2, the function will not be executed by that call if expression1 evaluates to true.

The result is true if either or both expressions evaluate to true; the result is false only if both expressions evaluate to false. You can use the logical OR operator with any number of operands; if any operand evaluates to true, the result is true.

Operands
expression1:Number — A Boolean value or an expression that converts to a Boolean value.
expression2:Number — A Boolean value or an expression that converts to a Boolean value.

Result
Boolean — The result of the logical operation.

Example
The following example uses the logical OR (||) operator in an if statement. The second expression evaluates to true, so the final result is true:
var x:Number = 10; 
var y:Number = 250; 
var start:Boolean = false; 
if ((x > 25) || (y > 200) || (start)) { 
    trace("the logical OR test passed"); // output: the logical OR test passed 
} 
The message the logical OR test passed appears because one of the conditions in the if statement is true (y>200). Although the other two expressions evaluate to false, as long as one condition evaluates to true, the if block executes.

The following example demonstrates how using a function call as expression2 can lead to unexpected results. If the expression on the left of the operator evaluates to true, that result is returned without evaluating the expression on the right (the function fx2() is not called).

function fx1():Boolean { 
    trace("fx1 called"); 
    return true; 
} 
function fx2():Boolean { 
    trace("fx2 called"); 
    return true; 
} 
if (fx1() || fx2()) { 
    trace("IF statement entered");
} 
The following is sent to the Output panel:The following is sent to the log file: fx1 called IF statement entered

See also

or logical ORoperator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the || (logical OR) operator.

Usage
condition1 or condition2

Player version: Flash Player 4

Evaluates condition1 and condition2, and if either expression is true, the whole expression is true.

Operands
condition1:Boolean — An expression that evaluates to true or false.
condition2:Boolean — An expression that evaluates to true or false.

Result
Boolean — The result of the logical operation.

See also

% modulooperator 
Usage
expression1 % expression2

Player version: Flash Player 4 — In Flash 4 files, the % operator is expanded in the SWF file as x - int(x/y) * y and may not be as fast or as accurate in later versions of Flash Player.

Calculates the remainder of expression1 divided by expression2. If either of the expression parameters are non-numeric, the modulo (%) operator attempts to convert them to numbers. The expression can be a number or string that converts to a numeric value.

The sign of the result of modulo operation matches the sign of the dividend (the first number). For example, -4 % 3 and -4 % -3 both evaluate to -1.

Operands
expression1:Number — A number or expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
Number — The result of the arithmetic operation.

Example
The following numeric example uses the modulo (%) operator:
trace(12%5); // traces 2 
trace(4.3%2.1); // traces 0.0999999999999996 
trace(4%4); // traces 0 
The first trace returns 2, rather than 12/5 or 2.4, because the modulo (%) operator returns only the remainder. The second trace returns 0.0999999999999996 instead of the expected 0.1 because of the limitations of floating-point accuracy in binary computing.

See also

%= modulo assignmentoperator 
Usage
expression1 %= expression2

Player version: Flash Player 4 — In Flash 4 files, the % operator is expanded in the SWF file as x - int(x/y) * y and may not be as fast or as accurate in later versions of Flash Player.

Assigns expression1 the value of expression1 % expression2. The following two statements are equivalent:

x %= y; 
x = x % y;

Operands
expression1:Number — A number or expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
Number — The result of the arithmetic operation.

Example
The following example assigns the value 4 to the variable x:
var x:Number = 14; 
var y:Number = 5; 
trace(x = y); // output: 4 

See also

* multiplicationoperator 
Usage
expression1 * expression2

Player version: Flash Player 4

Multiplies two numerical expressions. If both expressions are integers, the product is an integer. If either or both expressions are floating-point numbers, the product is a floating-point number.

Operands
expression1:Number — A number or expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
Number — An integer or floating-point number.

Example
Usage 1: The following statement multiplies the integers 2 and 3:
trace(2*3); // output: 6 
The result, 6, is an integer.
Usage 2: This statement multiplies the floating-point numbers 2.0 and 3.1416:
trace(2.0 * 3.1416); // output: 6.2832 
The result, 6.2832, is a floating-point number.

*= multiplication assignmentoperator 
Usage
expression1 *= expression2

Player version: Flash Player 4

Assigns expression1 the value of expression1 * expression2. For example, the following two expressions are equivalent:

x *= y;
x = x * y 

Operands
expression1:Number — A number or expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
Number — The value of expression1 * expression2 . If an expression cannot be converted to a numeric value, it returns NaN (not a number).

Example
Usage 1: The following example assigns the value 50 to the variable x:
var x:Number = 5; 
var y:Number = 10; 
trace(x *= y); // output: 50 
Usage 2: The second and third lines of the following example calculate the expressions on the right side of the equal sign and assign the results to x and y:
var i:Number = 5; 
var x:Number = 4 - 6; 
var y:Number = i + 2; 
trace(x *= y); // output: -14 

See also

newoperator 
Usage
new constructor()

Player version: Flash Player 5

Creates a new, initially anonymous, object and calls the function identified by the constructor parameter. The new operator passes to the function any optional parameters in parentheses, as well as the newly created object, which is referenced using the keyword this. The constructor function can then use this to set the variables of the object.

Operands
constructor:Object — A function followed by any optional parameters in parentheses. The function is usually the name of the object type (for example, Array, Number, or Object) to be constructed.

Example
The following example creates the Book() function and then uses the new operator to create the objects book1 and book2.
function Book(name, price){
  this.name = name;
  this.price = price;
}

book1 = new Book("Confederacy of Dunces", 19.95);
book2 = new Book("The Floating Opera", 10.95);
The following example uses the new operator to create an Array object with 18 elements:
golfCourse_array = new Array(18);

See also

ne not equal (strings)operator 

Deprecated since Flash Player 5 — This operator was deprecated in favor of the != (inequality) operator.

Usage
expression1 ne expression2

Player version: Flash Player 4

Compares expression1 to expression2 and returns true if expression1 is not equal to expression2; false otherwise.

Operands
expression1:Object — Numbers, strings, or variables.
expression2:Object — Numbers, strings, or variables.

Result
Boolean — Returns true if expression1 is not equal to expression2; false otherwise.

See also

{} object initializeroperator 
Usage
object = { name1 : value1 , name2 : value2 ,... nameN : valueN }
{expression1; [...expressionN]}

Player version: Flash Player 5

Creates a new object and initializes it with the specified name and value property pairs. Using this operator is the same as using the new Object syntax and populating the property pairs using the assignment operator. The prototype of the newly created object is generically named the Object object.

This operator is also used to mark blocks of contiguous code associated with flow control statements (for, while, if, else, switch) and functions.

Operands
object:Object — The object to create. name1,2,...N The names of the properties. value1,2,...N The corresponding values for each name property.

Result
Object

Usage 1: An Object object.

Usage 2: Nothing, except when a function has an explicit return statement, in which case the return type is specified in the function implementation.


Example
The first line of the following code creates an empty object using the object initializer ({}) operator; the second line creates a new object using a constructor function:
var object:Object = {}; 
var object:Object = new Object(); 
The following example creates an object account and initializes the properties name, address, city, state, zip, and balance with accompanying values:
var account:Object = {name:"Adobe", address:"601 Townsend Street", city:"San Francisco", state:"California", zip:"94103", balance:"1000"}; 
for (i in account) { 
    trace("account." + i + " = " + account[i]); 
} 
The following example shows how array and object initializers can be nested within each other:
var person:Object = {name:"Gina Vechio", children:["Ruby", "Chickie", "Puppa"]}; 
The following example uses the information in the previous example and produces the same result using constructor functions:
var person:Object = new Object(); 
person.name = "Gina Vechio"; 
person.children = new Array(); 
person.children[0] = "Ruby"; 
person.children[1] = "Chickie"; 
person.children[2] = "Puppa"; 
The previous ActionScript example can also be written in the following format:
var person:Object = new Object(); 
person.name = "Gina Vechio"; 
person.children = new Array("Ruby", "Chickie", "Puppa"); 

See also

() parenthesesoperator 
Usage
(expression1 [, expression2])
( expression1, expression2 )
function ( parameter1,..., parameterN ) 

Player version: Flash Player 4

Performs a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function outside the parentheses.

Usage 1: Controls the order in which the operators execute in the expression. Parentheses override the normal precedence order and cause the expressions within the parentheses to be evaluated first. When parentheses are nested, the contents of the innermost parentheses are evaluated before the contents of the outer ones.

Usage 2: Evaluates a series of expressions, separated by commas, in sequence, and returns the result of the final expression.

Usage 3: Surrounds one or more parameters and passes them as parameters to the function outside the parentheses.

Operands
expression1:Object — Numbers, strings, variables, or text.
expression2:Object — Numbers, strings, variables, or text.
function:Function — The function to be performed on the contents of the parentheses.
parameter1...parameterN:Object — A series of parameters to execute before the results are passed as parameters to the function outside the parentheses.

Example
Usage 1: The following statements show the use of parentheses to control the order in which expressions are executed (the value of each expression appears in the Output panel):

Usage 1: The following statements show the use of parentheses to control the order in which expressions are executed (the value of each expression is written to the log file):

trace((2 + 3)*(4 + 5)); // Output: 45 
trace((2 + 3) * (4 + 5)); // Output: 45trace(2 + (3 * (4 + 5))); // // writes 29 
trace(2 + (3 * (4 + 5))); // Output: 29trace(2+(3*4)+5); // writes 19 
trace(2 + (3 * 4) + 5); // Output: 19 
Usage 2: The following example evaluates the function foo(), and then the function bar(), and returns the result of the expression a + b:
var a:Number = 1; 
var b:Number = 2; 
function foo() { a += b; } 
function bar() { b *= 10; } 
trace((foo(), bar(), a + b)); // outputs 23 
Usage 3: The following example shows the use of parentheses with functions:
var today:Date = new Date(); 
trace(today.getFullYear()); // traces current year 
function traceParameter(param):Void { trace(param); } 
traceParameter(2 * 2); //traces 4 

See also

=== strict equalityoperator 
Usage
expression1 === expression2

Player version: Flash Player 6

Tests two expressions for equality; the strict equality (===)operator performs in the same way as the equality (==) operator, except that data types are not converted. The result is true if both expressions, including their data types, are equal.

The definition of equal depends on the data type of the parameter:

Operands
expression1:Object — A number, string, Boolean value, variable, object, array, or function.
expression2:Object — A number, string, Boolean value, variable, object, array, or function.

Result
Boolean — The Boolean result of the comparison.

Example
The comments in the following code show the returned value of operations that use the equality and strict equality operators:
// Both return true because no conversion is done 
var string1:String = "5"; 
var string2:String = "5"; 
trace(string1 == string2); // true 
trace(string1 === string2); // true 
// Automatic data typing in this example converts 5 to "5" 
var string1:String = "5"; 
var num:Number = 5; 
trace(string1 == num); // true 
trace(string1 === num); // false 
// Automatic data typing in this example converts true to "1" 
var string1:String = "1"; 
var bool1:Boolean = true; 
trace(string1 == bool1); // true 
trace(string1 === bool1); // false 
// Automatic data typing in this example converts false to "0" 
var string1:String = "0"; 
var bool2:Boolean = false; 
trace(string1 == bool2); // true 
trace(string1 === bool2); // false 
The following examples show how strict equality treats variables that are references differently than it treats variables that contain literal values. This is one reason to consistently use String literals and to avoid the use of the new operator with the String class.
// Create a string variable using a literal value 
var str:String = "asdf"; 
// Create a variable that is a reference 
var stringRef:String = new String("asdf"); 
// The equality operator does not distinguish among literals, variables, 
// and references 
trace(stringRef == "asdf"); // true 
trace(stringRef == str); // true 
trace("asdf" == str); // true 
// The strict equality operator considers variables that are references 
// distinct from literals and variables 
trace(stringRef === "asdf"); // false 
trace(stringRef === str); // false 

See also

!== strict inequalityoperator 
Usage
expression1 !== expression2

Player version: Flash Player 6

Tests for the exact opposite of the strict equality (=== )operator. The strict inequality operator performs the same as the inequality operator except that data types are not converted.

If expression1 is equal to expression2, and their data types are equal, the result is false. As with the strict equality (===) operator, the definition of equal depends on the data types being compared, as illustrated in the following list:

Operands
expression1:Object — A number, string, Boolean value, variable, object, array, or function.
expression2:Object — A number, string, Boolean value, variable, object, array, or function.

Result
Boolean — The Boolean result of the comparison.

Example
The comments in the following code show the returned value of operations that use the equality (==), strict equality (===), and strict inequality (!==) operators:
var s1:String = "5"; 
var s2:String = "5"; 
var s3:String = "Hello"; 
var n:Number = 5; 
var b:Boolean = true; 
trace(s1 == s2); // true 
trace(s1 == s3); // false 
trace(s1 == n); // true 
trace(s1 == b); // false 
trace(s1 === s2); // true 
trace(s1 === s3); // false 
trace(s1 === n); // false 
trace(s1 === b); // false 
trace(s1 !== s2); // false 
trace(s1 !== s3); // true 
trace(s1 !== n); // true 
trace(s1 !== b); // true 

See also

" string delimiteroperator 
Usage
"text"

Player version: Flash Player 4

When used before and after characters, quotation marks (") indicate that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.

Operands
text:String — A sequence of zero or more characters.

Example
The following example uses quotation marks (") to indicate that the value of the variable yourGuess is the literal string "Prince Edward Island" and not the name of a variable. The value of province is a variable, not a literal; to determine the value of province, the value of yourGuess must be located.
var yourGuess:String = "Prince Edward Island"; 
submit_btn.onRelease = function() { trace(yourGuess); }; 
// displays Prince Edward Island

See also

- subtractionoperator 
Usage
(Negation) -expression
(Subtraction) expression1 - expression2

Player version: Flash Player 4

Used for negating or subtracting.

Usage 1: When used for negating, it reverses the sign of the numerical expression.
Usage 2: When used for subtracting, it performs an arithmetic subtraction on two numerical expressions, subtracting expression2 from expression1. When both expressions are integers, the difference is an integer. When either or both expressions are floating-point numbers, the difference is a floating-point number.

Operands
expression1:Number — A number or expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
Number — An integer or floating-point number.

Example
Usage 1: The following statement reverses the sign of the expression 2 + 3:
trace(-(2+3)); // output: -5 
Usage 2: The following statement subtracts the integer 2 from the integer 5:
trace(5-2); // output: 3 
The result, 3, is an integer.
Usage 3: The following statement subtracts the floating-point number 1.5 from the floating-point number 3.25:
trace(3.25-1.5); // output: 1.75 
The result, 1.75, is a floating-point number.

-= subtraction assignmentoperator 
Usage
expression1 -= expression2

Player version: Flash Player 4

Assigns expression1 the value of expression1- expression2. For example, the following two statements are equivalent: x -= y ; x = x - y;

String expressions must be converted to numbers; otherwise, NaN (not a number) is returned.

Operands
expression1:Number — A number or expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
Number — The result of the arithmetic operation.

Example
The following example uses the subtraction assignment (-=) operator to subtract 10 from 5 and assign the result to the variable x:
var x:Number = 5; 
var y:Number = 10; 
x -= y; trace(x); // output: -5 
The following example shows how strings are converted to numbers:
var x:String = "5"; 
var y:String = "10"; 
x -= y; trace(x); // output: -5 

See also

: typeoperator 
Usage
[ modifiers ] var variableName : type
function functionName () : type { ... }
function functionName ( parameter1:type , ... , parameterN:type ) [ :type ]{ ... } 

Player version: Flash Player 6

Used for strict data typing; this operator specifies the variable type, function return type, or function parameter type. When used in a variable declaration or assignment, this operator specifies the variable's type; when used in a function declaration or definition, this operator specifies the function's return type; when used with a function parameter in a function definition, this operator specifies the variable type expected for that parameter.

Types are a compile-time-only feature. All types are checked at compile time, and errors are generated when there is a mismatch. Mismatches can occur during assignment operations, function calls, and class member dereferencing using the dot (.) operator. To avoid type mismatch errors, use strict data typing.

Types that you can use include all native object types, classes and interfaces that you define, and Function and Void. The recognized native types are Boolean, Number, and String. All built-in classes are also supported as native types.

Operands
variableName:Object — An identifier for a variable. type A native data type, class name that you have defined, or interface name. functionName An identifier for a function. parameter An identifier for a function parameter.

Example
Usage 1: The following example declares a public variable named userName whose type is String and assigns an empty string to it:
var userName:String = ""; 
Usage 2: The following example shows how to specify a function's parameter type by defining a function named randomInt() that takes a parameter named integer of type Number:
function randomInt(integer:Number):Number { 
    return Math.round(Math.random()*integer); 
} 
trace(randomInt(8)); 
Usage 3: The following example defines a function named squareRoot() that takes a parameter named val of the Number type and returns the square root of val, also a Number type:
function squareRoot(val:Number):Number { 
    return Math.sqrt(val); 
} 
trace(squareRoot(121)); 

See also

typeofoperator 
Usage
typeof(expression)

Player version: Flash Player 5

Evaluates the expression and returns a string specifying whether the expression is a String, MovieClip, Object, Function, Number, or Boolean value.

Operands
expression:Object — A string, movie clip, button, object, or function.

Result
String — A String representation of the type of expression. The following table shows the results of the typeof operator on each type of expression.

Expression Type Result
String string
Movie clip movieclip
Button object
Text field object
Number number
Boolean boolean
Object object
Function function

See also

voidoperator 
Usage
void expression

Player version: Flash Player 5

The void operator evaluates an expression and then discards its value, returning undefined. The void operator is often used in comparisons using the == operator to test for undefined values.

Operands
expression:Object — An expression to be evaluated.