Adobe® Flex® 4 Language Reference
Show Packages and Classes List |  Packages  |  Classes  |  Index  |  Appendixes
 
Operators 

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


  Arithmetic
 +additionAdds numeric expressions.
 --decrementSubtracts 1 from the operand.
 /divisionDivides expression1 by expression2.
 ++incrementAdds 1 to an 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 operand 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 shiftCount 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 shiftCount.
 ~bitwise NOTConverts expression to a 32-bit signed integer, and then applies a bitwise one's complement.
 |bitwise ORConverts expression1 and expression2 to 32-bit unsigned integers, and places a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1.
 >>bitwise right shiftConverts expression and shiftCount to 32-bit integers, and shifts all the bits in expression to the right by the number of places specified by the integer that results from the conversion of shiftCount.
 >>>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.
 ^bitwise XORConverts expression1 and expression2 to 32-bit unsigned integers, and places 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 assignmentPerforms 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 assignmentPerforms a bitwise right-shift operation and stores the result in expression.
 >>>=bitwise unsigned right shift and assignmentPerforms an unsigned bitwise right-shift operation and stores the result in expression.
 ^=bitwise XOR assignmentAssigns expression1 the value of expression1 ^ expression2.
  Comment
 /*..*/block comment delimiterDelimits one or more lines of script comments.
 //line comment delimiterIndicates the beginning of a script comment.
  Comparison
 ==equalityTests two expressions for equality.
 >greater thanCompares two expressions and determines whether expression1 is greater than expression2; if it is, the result is true.
 >=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).
 !=inequalityTests for the exact opposite of the equality (==) operator.
 <less thanCompares two expressions and determines whether expression1 is less than expression2; if so, the result is true.
 <=less than or equal toCompares two expressions and determines whether expression1 is less than or equal to expression2; if it is, the result is true.
 ===strict equalityTests two expressions for equality, but does not perform automatic data conversion.
 !==strict inequalityTests for the exact opposite of the strict equality (===) operator.
  Logical
 &&logical ANDReturns expression1 if it is false or can be converted to false, and expression2 otherwise.
 &&=logical AND assignmentAssigns expression1 the value of expression1 && expression2.
 !logical NOTInverts the Boolean value of a variable or expression.
 ||logical ORReturns expression1 if it is true or can be converted to true, and expression2 otherwise.
 ||=logical OR assignmentAssigns expression1 the value of expression1 || expression2.
  Other
 []array accessInitializes a new array or multidimensional array with the specified elements (a0, and so on), or accesses elements in an array.
  asEvaluates whether an expression specified by the first operand is a member of the data type specified by the second operand.
 ,commaEvaluates expression1, then expression2, and so on.
 ?:conditionalEvaluates expression1, and if the value of expression1 is true, the result is the value of expression2; otherwise the result is the value of expression3.
  deleteDestroys the object property specified by reference; the result is true if the property does not exist after the operation completes, and false otherwise.
 .dotAccesses class variables and methods, gets and sets object properties, and delimits imported packages or classes.
  inEvaluates whether a property is part of a specific object.
  instanceofEvaluates whether an expression's prototype chain includes the prototype object for function.
  isEvaluates whether an object is compatible with a specific data type, class, or interface.
 ::name qualifierIdentifies the namespace of a property, a method, an XML property, or an XML attribute.
  newInstantiates a class instance.
 {}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 arguments to a function that precedes the parentheses.
 /RegExp delimiterWhen used before and after characters, indicates that the characters have a literal value and are considered a regular expression (RegExp), not a variable, string, or other ActionScript element.
 :typeUsed for assigning a data type; this operator specifies the variable type, function return type, or function parameter type.
  typeofEvaluates expression and returns a string specifying the expression's data type.
  voidEvaluates an expression and then discards its value, returning undefined.
  String
 +concatenationConcatenates (combines) strings.
 +=concatenation assignmentAssigns expression1 the value of expression1 + expression2.
 "string delimiterWhen used before and after characters, indicates that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.
  XML
 @attribute identifierIdentifies attributes of an XML or XMLList object.
 { }braces (XML)Evaluates an expression that is used in an XML or XMLList initializer.
 [ ]brackets (XML)Accesses a property or attribute of an XML or XMLList object.
 +concatenation (XMLList)Concatenates (combines) XML or XMLList values into an XMLList object.
 +=concatenation assignment (XMLList)Assigns expression1, which is an XMLList object, the value of expression1 + expression2.
  delete (XML)Deletes the XML elements or attributes specified by reference.
 ..descendant accessorNavigates to descendant elements of an XML or XMLList object, or (combined with the @ operator) finds matching attributes of descendants.
 .dot (XML)Navigates to child elements of an XML or XMLList object, or (combined with the @ operator) returns attributes of an XML or XMLList object.
 ( )parentheses (XML)Evaluates an expression in an E4X XML construct.
 < >XML literal tag delimiterDefines an XML tag in an XML literal.
Operator Detail
+ addition Operator
Usage

expression1 + expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Adds numeric expressions. 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.

If one expression is a string, all other expressions are converted to strings and concatenated instead of summed. Otherwise, if an expression is not a number, Flash® Player converts it to a number.

Operands
expression1:Number — A value to be added.
expression2:Number — A value to be added.

Result
Number — An integer or floating-point number.

Example
How to use this example
This statement adds the integers 2 and 3:
trace(2 + 3); // 5
This statement adds the floating-point numbers 2.5 and 3.25:
trace(2.5 + 3.25); // 5.75
This example shows that if one expression is a string, all other expressions are converted to strings and concatenated:
trace("Number " + 8 + 0); // Number 80
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 of type String, 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 shown here:
var oldBalance:Number = 1345.23; 
var currentBalance:Number = Number(deposit_txt.text) + oldBalance;
trace(currentBalance);

See also

+= addition assignment Operator  
Usage

expression1 += expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

x += y; 
x = x + y; 
All the rules of the addition (+) operator apply to the addition assignment (+=) operator.

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

Result
Number — The result of the addition.

Example
How to use this example
The following example shows a numeric use of the addition assignment (+=) operator:
var x:Number = 5; 
var y:Number = 10; 
x += y; 
trace(x); // 15 

See also

[] array access Operator  
Usage

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

Runtime Versions: Flash Player 9

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 trace() statement finds the third element (index 2) of the second array (index 1).
var ticTacToe:Array = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; 
trace(ticTacToe[1][2]); // 6 
Usage 3: You can use the array access operator to dynamically set and retrieve values for a property of an object:
var obj:Object = new Object();
obj.prop1 = "foo";
trace(obj["prop" + 1]); // foo
obj.prop2 = "bar";
for (j in obj) {
	trace(obj[j]);
} 
/* Output of for loop: 
foo
bar */

Operands
myArray:Object — The name of an array.
a0, a1,...aN:Object — Elements in an array; any native type or object instance, including nested arrays.
i:Number — An integer index greater than or equal to 0.
myObject:Object — The name of an object.
propertyName:String — 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
How to use this 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 with three elements and changes the third element in the array.

var employee_array = ["Barbara", "George", "Mary"]; 
trace(employee_array); // Barbara,George,Mary 
employee_array[2] = "Sam"; 
trace(employee_array); // Barbara,George,Sam 
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 the obj object:
var obj:Object = new Object();
obj.prop1 = "foo";
obj.prop2 = "bar";

for (var i:int = 1;i < 3;i++) {
	trace(obj["prop"+i]);
}
/* Output of for loop:
foo
bar */ 

See also

 as Operator  
Usage

expression as datatype

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates whether an expression specified by the first operand is a member of the data type specified by the second operand. If the first operand is a member of the data type, the result is the first operand. Otherwise, the result is the value null.

The expression used for the second operand must evaluate to a data type.

Operands
expression:* — The value to check against the data type specified.
datatype:Class — The data type used to evaluate the expression operand. The special * type, which means untyped, cannot be used.

Result
Object — The result is expression if expression is a member of the data type specified in datatype. Otherwise, the result is the value null.

Example
How to use this example
The following example creates a simple array named myArray and uses the as operator with various data types.
public var myArray:Array = ["one", "two", "three"];
trace(myArray as Array);  // one,two,three
trace(myArray as Number); // null
trace(myArray as int);    // null

See also

= assignment Operator  
Usage

expression1 = expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Assigns the value of expression2 (the operand 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 expression2 is a primitive value, which means that its data type is either Boolean, Number, int, uint, or String. Assignment by reference stores a reference to expression2 in expression1. Assignment by reference is commonly used with the new operator. The new operator creates an object in memory, and a reference to that location in memory is assigned to a variable.

Note: In ActionScript 3.0 all values (including primitive values) are objects, and all assignment is done by reference, but primitive objects have special operators that allow them to behave as if they are assigned by value.

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

Result
Object — The assigned value, expression2.

Example
How to use this example
The following example uses assignment by value to assign the value of 5 to the variable z.
var z:Number = 5;
The following example uses assignment by value to assign the value "hello" to the variable z:
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); // 3030
The following example builds on 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. You can then change the diameter property to use kilometers instead of miles:
var merkur:Object = mercury;
merkur.diameter = 4878;  // in kilometers
trace(mercury.diameter); // 4878

See also

@ attribute identifier Operator  
Usage

 myXML.@attributeName 

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Identifies attributes of an XML or XMLList object. For example, myXML.@id identifies attributes named id for the myXML XML object. You can also use the following syntax to access attributes: myXML.attribute("id"), myXML["@id"], and myXML.@["id"]. The syntax myXML.@id is recommended. To return an XMLList object of all attribute names, use @~~. To return an attribute with a name that matches an ActionScript reserved word, use the attribute() method instead of the @ operator.

Operands
attributeName:* — The name of the attribute.

Example
How to use this example
The first example shows how to use the @ (at sign) operator to identify an attribute of an element:
var myXML:XML = 
	<item id = "42">
		<catalogName>Presta tube</catalogName>
		<price>3.99</price>
	</item>;

trace(myXML.@id); // 42
The next example returns all attribute names:
var xml:XML =<example id='123' color='blue'/>
 var xml2:XMLList = xml.@~~;
 trace(xml2 is XMLList); // true
 trace(xml2.length());  // 2
 for (var i:int = 0; i < xml2.length(); i++)
 { 
	trace(typeof(xml2[i]));    // xml
	trace(xml2[i].nodeKind()); // attribute
	trace(xml2[i].name());     // id and color
 } 
The next example returns an attribute with a name that matches a reserved word in ActionScript. You cannot use the syntax xml.@class (since class is a reserved word in ActionScript). You need to use the syntax xml.attribute("class"):
var xml:XML = <example class='123'/>
trace(xml.attribute("class"));

See also

& bitwise AND Operator  
Usage

expression1 & expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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.

A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit two's complement number, so the result is an integer in the range -2147483648 to 2147483647.

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

Result
int — The result of the bitwise operation.

Example
How to use this example
The following example performs a bitwise AND of 13 (binary 1101) and 11 (binary 1011) by comparing the bit representations of the numbers. The resulting integer is composed of a sequence of bits, each of which is set to 1 only if the bits of both operands at the same position are 1.
var insert:Number = 13; 
var update:Number = 11; 
trace(insert & update); // 9 (or 1001 binary) 
The bitwise AND of 13 (binary 1101) and 11 (binary 1011) is 9 because only the first and last positions in both numbers have the number 1.
  1101
& 1011
  ----
  1001

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 assignment Operator  
Usage

expression1 &= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
int — The value of expression1 & expression2.

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

See also

<< bitwise left shift Operator  
Usage

expression1 << shiftCount

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Converts expression1 and shiftCount 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 shiftCount. The bit positions that are emptied as a result of this operation are filled in with 0 and bits shifted off the left end are discarded. Shifting a value left by one position is the equivalent of multiplying it by 2.

A floating-point number is converted to an integer by discarding any digits after the decimal point. A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit two's complement number, so the result is an integer in the range -2147483648 to 2147483647.

If the result is a negative integer, a runtime error occurs if you attempt to assign the result to a variable of type uint. Although ActionScript has no "unsigned bitwise left shift" operator, you can achieve the same effect, and avoid the runtime error, by using uint(expression1 << shiftCount):

var num1:uint = 0xFF;
var num2:uint = uint(num1 << 24); // uint() prevents runtime error

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

Result
int — The result of the bitwise operation.

Example
How to use this example
In the following example, the integer 1 is shifted 10 bits to the left:
x = 1 << 10
The result of the bitwise left shift operation is 1024. This is because 1 decimal equals 1 binary, 1 binary shifted left by 10 is 10000000000 binary, and 10000000000 binary is 1024 decimal:
   00000000001 binary 
<<          10 decimal
--------------
   10000000000 binary equals 1024 decimal 

In the following example, the integer 7 is shifted 8 bits to the left:

x = 7 << 8
The result of the bitwise left shift operation is 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:
   00000000111 binary 
<<           8 decimal
--------------
   11100000000 binary equals 1792 decimal 

The following trace statement shows that the bits have been pushed three positions to the left:

// 1 binary == 0001 
// 8 binary == 1000 
trace(1 << 3); // 8 

See also

<<= bitwise left shift and assignment Operator  
Usage

expression1 <<= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
int — The result of the bitwise operation.

Example
How to use this example
The following example uses the bitwise left shift and assignment (<<=) operator to shift all bits one position to the left:
var x:Number = 4; 
// Shift all bits one slot to the left. 
x <<= 1; 
trace(x); // 8 
// 4 decimal = 0100 binary 
// 8 decimal = 1000 binary 

See also

~ bitwise NOT Operator  
Usage

~expression

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Converts 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. This operator is also known as the one's complement operator or the bitwise complement operator.

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).

A floating-point number is converted to an integer by discarding any digits after the decimal point. A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit two's complement number, so the result is an integer in the range -2147483648 to 2147483647.

Operands
expression:Number — A number to be converted.

Result
int — The result of the bitwise operation.

Example
How to use this example
The following example demonstrates a use of the bitwise NOT (~) operator with flag bits:
var ReadOnlyFlag:int = 0x0001; // defines bit 0 as the read-only flag 
var flags:int = 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); 
// 0 1 0 

See also

| bitwise OR Operator  
Usage

expression1 | expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Converts expression1 and expression2 to 32-bit unsigned integers, and places a 1 in each bit position where the corresponding bits of either expression1 or expression2 are 1.

A floating-point number is converted to an integer by discarding any digits after the decimal point. A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit two's complement number, so the result is an integer in the range -2147483648 to 2147483647.

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

Result
int — The result of the bitwise operation.

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

See also

|= bitwise OR assignment Operator  
Usage

expression1 |= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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 to be converted.
expression2:Number — A number to be converted.

Result
int — The result of the bitwise operation.

Example
How to use this example
The following example uses the bitwise OR assignment (|=) operator:
// 15 decimal = 1111 binary 
var a:Number = 15; 
// 9 decimal = 1001 binary 
var b:Number = 9; 
// 1111 |= 1001 = 1111 
trace(a |= b); // returns 15 decimal (1111 binary) 

See also

>> bitwise right shift Operator  
Usage

expression >> shiftCount

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Converts expression and shiftCount to 32-bit integers, and shifts all the bits in expression to the right by the number of places specified by the integer that results from the conversion of shiftCount. 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 expression 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.

A floating-point number is converted to an integer by discarding any digits after the decimal point. A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit two's complement number, so the result is an integer in the range -2147483648 to 2147483647.

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

Result
int — The result of the bitwise operation.

Example
How to use this example
The following example converts 65535 to a 32-bit integer and shifts it 8 bits to the right, resulting in a decimal value of 255:
var a:Number = 65535 >> 8; 
trace(a); // 255
This is because 65535 decimal equals 00000000000000001111111111111111 binary (sixteen 0s followed by sixteen 1s); shifting right by 8 bits causes the 8 least significant bits (the bits farthest to the right) to be discarded. Because 65535 is positive, the bit position made available by the shift (the 8 bit positions farthest on the left) are filled in with 0s. The result is 00000000000000000000000011111111 (twenty-four 0s followed by eight 1s) binary, which represents the 32-bit integer 255.
    00000000000000001111111111111111 binary (65535 decimal)
>>                                 8 decimal
--------------------
    00000000000000000000000011111111 binary (255 decimal)
The following example converts -8 to a 32-bit integer and shifts it 1 bit to the right, resulting in a decimal value of -4:
var a:Number = -8 >> 1;
trace(a); // -4
This is because -8 decimal equals 11111111111111111111111111111000 binary (twenty-nine 1s followed by three 0s); shifting right by one bit causes the least significant bit (the bit farthest to the right) to be discarded. Because -8 is negative, the bit position made available by the shift (the 1 bit position farthest on the left) is filled in with 1. The result is 11111111111111111111111111111100 (thirty 1s followed by two 0s) binary, which represents the 32-bit integer -4.
    11111111111111111111111111111000 binary (-8 decimal)
>>							    1 decimal
--------------------
    11111111111111111111111111111100 binary (-4 decimal)

See also

>>= bitwise right shift and assignment Operator  
Usage

expression >>= shiftCount

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Performs a bitwise right-shift operation and stores the result in expression.

The following two statements are equivalent:

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

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

Result
int — The result of the bitwise operation.

Example
How to use this example
The following 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.
		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 shift Operator  
Usage

expression >>> shiftCount

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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.

A floating-point number is converted to an integer by discarding any digits after the decimal point. A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit unsigned integer, so the result is an integer in the range 0 to 4294967295.

Note: ActionScript has no complementary "bitwise unsigned left shift" operator, but you can achieve the same effect by using uint(expression << shiftCount).

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

Result
uint — The result of the bitwise operation.

Example
How to use this example
The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right:
var a:Number = -1 >>> 1; 
trace(a); // 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 assignment Operator  
Usage

expression >>>= shiftCount

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

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

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

Result
uint — The result of the bitwise operation.

Example
How to use this example
The following example converts -1 to a 32-bit integer and shifts it 1 bit to the right:
var a:Number = -1;
a >>>= 1; 
trace(a); // 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 XOR Operator  
Usage

expression1 ^ expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Converts expression1 and expression2 to 32-bit unsigned integers, and places a 1 in each bit position where the corresponding bits in expression1 or expression2, but not both, are 1.

A floating-point number is converted to an integer by discarding any digits after the decimal point. A positive integer is converted to an unsigned hexadecimal value with a maximum value of 4294967295 or 0xFFFFFFFF; a value larger than the maximum has its most significant digits discarded when it is converted so the value is still 32-bit. A negative number is converted to an unsigned hexadecimal value using the two's complement notation, with a minimum value of -2147483648 or 0x800000000; a number less than the minimum is converted to two's complement with greater precision before the most significant digits are discarded.

The result is interpreted as a 32-bit two's complement number, so the result is an integer in the range -2147483648 to 2147483647.

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

Result
int — The result of the bitwise operation.

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

See also

^= bitwise XOR assignment Operator  
Usage

expression1 ^= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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 expression that evaluates to a number.
expression2:Number — A number or expression that evaluates to a number.

Result
int — The result of the bitwise operation.

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

See also

/*..*/ block comment delimiter Operator  
Usage

/* comment */
/* comment
   comment */

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Delimits one or more lines of script comments. Characters that appear between the opening delimiter (/*) and the closing delimiter (*/) are interpreted as a comment and ignored by the ActionScript compiler. Use these delimiters to identify comments on multiple successive lines; for single-line comments, use the // delimiter.

You will receive an error message if you omit the closing block comment delimiter (*/), or if you attempt to nest comments. After an opening delimiter (/*) is used, the first closing delimiter (*/) ends the comment, regardless of the number of opening delimiters placed before it.

Operands
comment:* — Any characters.

Example
How to use this example
The following script uses block 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 results 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

{ } braces (XML) Operator  
Usage

 myXML = <{tagName} {attributeName} = {attributeValue}>{content}

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates an expression that is used in an XML or XMLList initializer. An XML or XMLList initializer is a literal value that is assigned to a variable of type XML or XMLList. An expression that is delimited by the XML { and } operators can be used in an XML or XMLList initializer instead of literal names or values. An expression can be used in place of tagName, attributeName, attributeValue, and content.

Operands
myXML:* — An XML or XMLList object.
tagName:* — An expression that evaluates to the name of an XML tag.
attributeName:* — An expression that evaluates to the name of an XML attribute.
attributeValue:* — An expression that evaluates to the value of an XML attribute.
content:* — An expression that evaluates to the contents of an XML tag.

Example
How to use this example
The following example shows how to use the { and } operators when defining an XML literal:
var tagname:String = "item"; 
var attributename:String = "id"; 
var attributevalue:String = "5"; 
var content:String = "Chicken"; 
var x:XML = <{tagname} {attributename}={attributevalue}>{content}</{tagname}>; 
trace(x.toXMLString()); // <item id="5">Chicken</item>

See also

[ ] brackets (XML) Operator  
Usage

 myXML[expression]

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Accesses a property or attribute of an XML or XMLList object. The brackets operator allows you to access property names that are not accessible with the dot (.) operator.

Operands
myXML:* — An XML or XMLList object.
expression:* — An expression that evaluates to the name of an XML tag or attribute.

Example
How to use this example
The following example shows how to use the [ and ] operators to access an XML property that is not accessible with the dot operator because of the hyphen in the tag name:
var myXML:XML = <a><foo-bar>44</foo-bar></a>;
trace(myXML["foo-bar"]);

See also

, comma Operator  
Usage

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

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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:* — An expression to be evaluated.
expression2:* — An expression to be evaluated.
expressionN:* — Any number of additional expressions to be evaluated.

Result
Object — The values of the evaluated expressions.

Example
How to use this 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 the assignment (=) operator:
var v:Number = 0; 
v = 4, 5, 6; 
trace(v); // 4 
The following example uses the comma operator with parentheses and illustrates that the comma operator returns the value of the last expression:
var v:Number = 0; 
v = (4, 5, 6); 
trace(v); // 6 
The following example uses the comma operator without parentheses and illustrates that the comma operator causes all of the expressions to be evaluated sequentially. 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); // 4 
trace(z); // 1 
The following example is identical to the previous example except for the addition of parentheses, 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); // 6 
trace(z); // 1 

See also

+ concatenation Operator  
Usage

expression1 + expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Concatenates (combines) strings. If one expression is a string, all other expressions are converted to strings and concatenated.

If both expressions are numbers, this operator behaves as an addition operator.

Operands
expression1:String — A string to be concatenated.
expression2:String — A string to be concatenated.

Result
String — The concatenated string.

Example
How to use this example
The following example concatenates two strings.
var lastName:String = "Cola"; 
var instrument:String = "Drums"; 
trace(lastName + " plays " + instrument); // Cola plays Drums 
This example shows that if one expression is a string, all other expressions are converted to strings and concatenated:
trace("Number " + 8 + 0); // Number 80
The following example shows how numeric sums to the right of a string expression are not calculated because they are converted to strings:
var a:String = 3 + 10 + "asdf"; 
trace(a); // 13asdf 
var b:String = "asdf" + 3 + 10; 
trace(b); // asdf310 

See also

+ concatenation (XMLList) Operator  
Usage

expression1 + expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Concatenates (combines) XML or XMLList values into an XMLList object. An XMLList object results only if both operands are XML or XMLList values.

Operands
expression1:* — An XML or XMLList value.
expression2:* — An XML or XMLList value.

Result
XMLList — The concatenated XMLList object.

Example
How to use this example
The following example shows how to use the XMLList (+) (concatenation) operator:
var x1:XML = 
		<employee id = "42">
			<firstName>Joe</firstName>
			<lastName>Smith</lastName>
		</employee>;

var x2:XML = 
		<employee id = "43">
			<firstName>Susan</firstName>
			<lastName>Jones</lastName>
		</employee>;

var myXMLList:XMLList = x1 + x2;
	
trace(myXMLList.toXMLString()); 

The trace statement produces the following output:

<employee id = "42">
	<firstName>Joe</firstName>
	<lastName>Smith</lastName>
</employee>
<employee id = "43">
	<firstName>Susan</firstName>
	<lastName>Jones</lastName>
</employee>
	

See also

+= concatenation assignment Operator  
Usage

expression1 += expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

x += y; 
x = x + y;
All the rules of the concatenation (+) operator apply to the concatenation assignment (+=) operator. Note that using concatenation assignment for the text property of a TextField (i.e. someTextField.text += moreText is much less efficient than TextField.appendText(), particularly with a TextField that contains a significant amount of content.

Operands
expression1:String — A string.
expression2:String — A string.

Result
Number — The result of the concatenation.

Example
How to use this example
This example uses the += operator with a string expression:
var x1:String = "My name is "; 
x1 += "Gilbert"; 
trace(x1); // My name is Gilbert 

See also

+= concatenation assignment (XMLList) Operator  
Usage

expression1 += expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Assigns expression1, which is an XMLList object, the value of expression1 + expression2. For example, the following two statements have the same result:

x += y; 
x = x + y; 
All the rules of the XMLList concatenation (+) operator apply to the XMLList concatenation assignment (+=) operator.

Operands
expression1:XMLList — The XMLList object to which you are adding a new value.
expression2:* — An XML or XMLList value.

Example
How to use this example
The following example shows how to use the XMLList concatenation assignment (+=) operator:
var x1:XML = <location>Athens</location>;	
var x2:XML = <location>Paris</location>;		
myXMLList = x1 + x2;

var x3:XML = <location>Springfield</location>;
myXMLList += x3;
		    
trace(myXMLList.toXMLString());

The trace statement produces the following output:

<location>Athens</location>
	
<location>Paris</location>	

<location>Springfield</location>

See also

?: conditional Operator  
Usage

expression1 ? expression2 : expression3

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates expression1, and if the value of expression1 is true, the result is the value of expression2; otherwise the result is the value of expression3.

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

Result
* — The value of expression2 or expression3.

Example
How to use this example
The following statement assigns the value of variable x to variable z because the first expression 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); 

-- decrement Operator  
Usage

--expression
expression--

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Subtracts 1 from the operand. The operand 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 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
How to use this 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); 
}

 delete Operator  
Usage

 delete reference

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Destroys the object property specified by reference; the result is true if the property does not exist after the operation completes, and false otherwise. The delete operator returns true if it is called on a nonexistent property or a dynamic property not defined in a class.

The delete operator can fail and return false if the reference parameter cannot be deleted. You cannot delete fixed properties or variables that are declared with the var statement. A fixed property is a variable or method defined in a class definition.

The delete operator cannot be used to destroy a property of a class, unless that class is a dynamic class added at runtime. Properties of sealed classes cannot be destroyed using delete. Set the property to null instead.

Note: You cannot delete an object, but you can make an object eligible for garbage collection by removing all references to the object. The most common reference to an object is a variable that points to it. You can remove such a reference by setting the variable to null. The garbage collector removes any object that has no references.

Operands
reference:* — The name of the property to eliminate.

Result
Boolean — The value true if the deletion succeeded and false if it failed.

Example
How to use this example
The following example deletes a property of an object:
// create the new object "account" 
var account:Object = new Object(); 
// assign property name to the account 
account.name = "Jon"; 
// delete the property 
delete account.name; 
trace(account.name); // undefined

// delete a nonexistent property
var fooDeleted:Boolean = delete account.foo;
trace(fooDeleted); // true

The following example deletes the value of an array element, but the value of the length property is not changed:

var my_array:Array = new Array(); 
my_array[0] = "abc"; // my_array.length == 1 
my_array[1] = "def"; // my_array.length == 2 
my_array[2] = "ghi"; // my_array.length == 3 
// my_array[2] is deleted, but Array.length is not changed 
delete my_array[2]; 
trace(my_array.length); // 3 
trace(my_array); // abc,def,

The following example shows how the returned Boolean from delete can be used as a condition for future code execution. Note that if an item has already been deleted, calling delete on the item again will return false.

var my_array:Array = [ "abc", "def", "ghi" ];
var deleteWasSuccessful:Boolean

deleteWasSuccessful = delete my_array[0];
if(deleteWasSuccessful) delete my_array[1];
deleteWasSuccessful = delete my_array[0];
if(deleteWasSuccessful) delete my_array[2];

trace(my_array) // outputs: undefined,undefined,ghi

See also

 delete (XML) Operator  
Usage

 delete reference

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Deletes the XML elements or attributes specified by reference.

Operands
reference:XMLList — An XMLList object that specifies the XML elements or attributes to delete.

Result
Boolean — Always returns a value of true. The result is always true because the XMLList operand always refers to a valid (though possibly empty) XMLList object.

Example
How to use this example
The following example shows how to delete an attribute, then delete a single element, then delete multiple elements:
 
var x1:XML = <x1>
				<a id = "52">AYY</a>
				<a>AYY 2 </a>
				<b>BEE</b>
				<c>CEE</c>
			</x1>;

trace(x1.toXMLString());
trace("___________");

delete x1.a.@id;

trace(x1.toXMLString());
trace("___________");

delete x1.b;

trace(x1.toXMLString());
trace("___________");

delete x1.a;

trace(x1.toXMLString());

The output is as follows:

<x1>
  <a id="52">AYY</a>
  <a>AYY 2</a>
  <b>BEE</b>
  <c>CEE</c>
</x1>
___________
<x1>
  <a>AYY</a>
  <a>AYY 2</a>
  <b>BEE</b>
  <c>CEE</c>
</x1>
___________
<x1>
  <a>AYY</a>
  <a>AYY 2</a>
  <c>CEE</c>
</x1>
___________
<x1>
  <c>CEE</c>
</x1>

The following example shows how to delete all contents of an element, including attributes and child elements, without deleting the element itself:
 
var xml:XML = 
			<order>
				<item id="121">hamburger</item>
				<item id="122">fries</item>
				<item id="123">chocolate shake</item>
			</order>;
delete xml.item[1].*;
delete xml.item[1].@*;
trace(xml);

The output for this example is the following:

<order>
  <tem id="121">hamburger</item>
  <item/>
  <item id="123">chocolate shake</item>
</order>

.. descendant accessor Operator  
Usage

 myXML..childElement1..@attributeName 

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Navigates to descendant elements of an XML or XMLList object, or (combined with the @ operator) finds matching attributes of descendants. The matching elements or attributes need not be direct children of the XML or XMLList object; they can be lower in the tree (for example, grandchildren). The result is an XMLList object, because more than one child element or attribute can match.

The order of nodes in the XMLList object returned is the result of a depth-first traversal. For example, consider the following:

var myXML:XML = <a>
			<b>one
				<c> 
					<b>two</b> 
				</c> 
			</b>
			<b>three</b>
		</a>;

trace(myXML..b[0].toXMLString());
trace("______________");
trace(myXML..b[1].toXMLString());
trace("______________");
trace(myXML..b[2].toXMLString());

The following output would result:

<b>
  one
  <c>
    <b>two</b>
  </c>
</b>
______________
<b>two</b>
______________
<b>three</b>

To return descendants with names that match ActionScript reserved words, use the XML.descendants() method instead of the descendant (..) operator, as the following example shows:

var xml:XML = 
<enrollees>
	<student id="239">
		<class name="Algebra" />
 		<class name="Spanish 2"/>
	</student>
	<student id="206">
		<class name="Trigonometry" />
 		<class name="Spanish 2" />
	</student>
 </enrollees>;
 trace(xml.descendants("class")); 
 

Operands
myXML:Object — The XML or XMLList object.
childElement1_or_attributeName — The name of an XML property or the name of an attribute.

Example
How to use this example
The following example shows how to use the descendant accessor (..) operator to return descendant elements of an XML object and to return an attribute of an element:
var myXML:XML = 
	<employees>
		<employee id = "42">
			<firstName>Billy</firstName>
			<lastName>Einstein</lastName>
		</employee>
		<employee id = "43">
			<firstName>Sally</firstName>
			<lastName>Shostakovich</lastName>
		</employee>
	</employees>
	
trace(myXML..firstName); 
	// <firstName>Billy</firstName>
	// <firstName>Sally</firstName>
				
trace(myXML..@id); //4243

See also

/ division Operator  
Usage

expression1 / expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
How to use this example
The following example shows that the results of dividing by 0 differs if the dividend is positive, negative or 0.
trace(3/0);   // Infinity
trace(-3/0);  // -Infinity
trace(0/0);   // NaN

See also

/= division assignment Operator  
Usage

expression1 /= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
How to use this example
The following code shows the division assignment (/=) operator used with variables and numbers:
var a:Number = 10; 
var b:Number = 2; 
a /= b; trace(a); // 5 

See also

. dot Operator  
Usage

object.property_or_method

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Accesses class variables and methods, gets and sets object properties, and delimits imported packages or classes.

Operands
object:Object — An instance of a class. The object can be an instance of any of the built-in ActionScript classes or a class you define. This operand 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 operand is always to the right of the dot (.) operator.

Result
* — The variable, method, or property named on the right side of the dot.

Example
How to use this example
The following example uses the dot operator as a delimiter when importing the Timer class.
import flash.utils.Timer;
The following example creates a generic object and uses the dot operator to add a new property.
var obj:Object = new Object();
obj.propertyA = "hello";
trace(obj.propertyA);  // hello

See also

. dot (XML) Operator  
Usage

myXML.childElement
myXML.@attributeName 

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Navigates to child elements of an XML or XMLList object, or (combined with the @ operator) returns attributes of an XML or XMLList object. The object returned is an XMLList, because more than one child element or attribute can match.

To return elements with names that match ActionScript reserved words, use the XML.elements() method or the XML.descendants() method instead of the XML dot (.) operator, as the following example shows:

var xml:XML = 
	<student id="206">
		<class name="Trigonometry" />
		<class name="Spanish 2" />
	</student>;
trace(xml.elements("class"));
trace(xml.descendants("class")); 

Operands
myXML:Object — The XML or XMLList object.
childElement:* — The name of an XML property.
attributeName:* — The name of an attribute.

Result
XMLList — The XMLList specified.

Example
How to use this example
The following example shows how to use the dot (.) operator to return to a child element of an XML object and to return an attribute of an element:
var myXML:XML = 
	<employee id = "42">
		<firstName>Billy</firstName>
		<lastName>Einstein</lastName>
	</employee>;

trace(myXML.firstName); // Billy
trace(myXML.@id);       // 42

See also

== equality Operator  
Usage

expression1 == expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

If the data types of the two operands match, the definition of equal depends on the data type of the operands:

  • Values of type int, uint, and Boolean are considered equal if they have the same value.
  • Numbers with matching values are considered equal, unless they are both NaN.
  • If the value of both operands is null or undefined, they are considered equal.
  • String expressions are equal if they have the same number of characters and the characters are identical.
  • For XML objects:
    • If one operand is a text or attribute node and the other has simple content, both operands are converted to strings with the toString() method and are considered equal if the resulting strings match.
    • Otherwise, objects are considered equal only if the qualified name, attributes, and child properties for both objects match.
  • XMLList objects are considered equal if they have the same number of properties and both the order and values of the properties match.
  • For Namespace objects, values are considered equal if the uri properties of both objects match.
  • For QName objects, values are considered equal if the uri properties of both objects match and the localName properties of both objects match.
  • Variables representing objects, arrays, and functions are compared by reference. Two such variables are equal if they refer to the same object, array, or function. Two separate arrays are never considered equal, even if they have the same number of elements.
If the data types of the operands do not match, the result is false except in the following circumstances:
  • The operands' values are undefined and null, in which case the result is true.
  • Automatic data type conversion converts the data types of String, Boolean, int, uint, and Number values to compatible types and the converted values are equal, in which case operands are considered equal.
  • One operand is of type XML with simple content (hasSimpleContent() == true), and after both operands are converted to strings with the toString() method, the resulting strings match.
  • One operand is of type XMLList, and either of the following conditions is true:
    • The length property of the XMLList object is 0, and the other object is undefined.
    • The length property of the XMLList object is 1, and one element of the XMLList object matches the other operand.

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

Result
Boolean — A value of true if the expressions are equal, and false otherwise.

Example
How to use this example
The following example uses the equality (==) operator with an if statement:
var a:String = "David"
var b:String = "David"; 
if (a == b) { 
	trace("David is David"); 
} 
The following examples show how the equality operator does automatic type conversion when comparing by value. String values are converted to numbers:
var a:Number = 5; 
var b:String = "5"; 
trace(a == b); // true
Boolean values are converted to numbers, where true is converted to 1 and false is converted to 0:
var c:Number = 1; 
var d:Boolean = true; 
trace(c == d); // true
var e:Number = 0; 
var f:Boolean = false; 
trace(e == f); // true
However, string values are not converted to Boolean values, so the following returns false:
var g:String = "true";
var h:Boolean = true;
trace(g == h); // false
The following examples show comparison by reference. The first example compares two arrays with identical length and elements. The equality operator returns false for these two arrays. Although the arrays appear equal, comparison by reference requires that both firstArray and secondArray refer to the same array. The second example creates the thirdArray variable, which points to the same array as firstArray. The equality operator returns 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); // false 
/* Arrays are only considered equal 
if the variables refer to the same array. */
var thirdArray:Array = firstArray; 
trace(firstArray == thirdArray); // true 

See also

> greater than Operator  
Usage

expression1 > expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Compares two expressions and determines whether expression1 is greater than expression2; if it is, the result is true. If expression1 is less than or equal to expression2, the result is false.

If both operands are of type String, the operands are compared using alphabetical order; all capital letters come before lowercase letters. Otherwise, operands are first converted to numbers, then compared.

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

Result
Boolean — A value of true if expression1 is greater than expression2; false otherwise.

Example
How to use this example
The following example shows that strings are compared alphabetically, with capital letters before lowercase letters:
var a:String = "first";
var b:String = "First";
trace(a > b); // true
The following example shows how String and Boolean values are converted to numbers:
var c:Number = 5;
var d:String = "4";
trace(c > d); // true

var e: Number = 2;
var f:Boolean = true;
trace(e > f); // true

>= greater than or equal to Operator  
Usage

expression1 >= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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 — A value of true if expression1 is greater than or equal to expression2; false otherwise.

Example
How to use this 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"); 
}

See also

 in Operator  
Usage

expression1 in expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates whether a property is part of a specific object. To use the in operator, specify a property name as the first operand and an object as the second operand. If the object you specify contains such a property, the result is true; otherwise the result is false.

If the specified object is an Array object, you can use the in operator to check whether a particular index number is valid. If you pass an integer as the first operand, the result is true if the index is within the valid range of index numbers, and false otherwise.

Result
Boolean — A value of true if expression1 is a property of the object represented by expression2, and false otherwise.

Example
How to use this example
The following example uses the in operator to show that PI is a property of the Math object, but that myProperty is not.
trace("PI" in Math);         // true
trace("myProperty" in Math); // false

The following example uses the in operator to show that the numbers 0, 1, and 2 are valid index numbers in the myArray object, but that the number 3 is not.

public var myArray:Array = ["zero", "one", "two"];
trace(0 in myArray); // true
trace(1 in myArray); // true
trace(2 in myArray); // true
trace(3 in myArray); // false

See also

++ increment Operator  
Usage

++expression
 expression++

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Adds 1 to an expression. The expression can be a variable, an element in an array, or a 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).

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

Result
Number — The result of the increment.

Example
How to use this example
The following example uses ++ as a pre-increment operator in a while loop to show that the value added to the array is the value that has been incremented:
var preInc:Array = new Array(); 
var i:int = 0; 
while (i < 10) { 
    preInc.push(++i); 
} 
trace(preInc); // 1,2,3,4,5,6,7,8,9,10 
The following example uses ++ as a post-increment operator in a whileloop to show that the value added to the array is the initial value:
 
var postInc:Array = new Array(); 
var i:int = 0; 
while (i < 10) { 
   postInc.push(i++); 
} 
trace(postInc); // 0,1,2,3,4,5,6,7,8,9 
The following example uses ++ as a post-increment operator to make a whileloop run five times:
var i:int = 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 
*/

!= inequality Operator  
Usage

expression1 != expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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.

If the data types of the two operands match, the definition of equal depends on the data type of the operands:

  • Values of type int, uint, and Boolean are considered equal if they have the same value.
  • Numbers with matching values are considered equal, unless they are both NaN.
  • If the value of both operands is null or undefined, they are considered equal.
  • String expressions are equal if they have the same number of characters and the characters are identical.
  • For XML objects:
    • If one operand is a text or attribute node and the other has simple content, both operands are converted to strings with the toString() method and are considered equal if the resulting strings match.
    • Otherwise, objects are considered equal only if the qualified name, attributes, and child properties for both objects match.
  • XMLList objects are considered equal if they have the same number of properties and both the order and values of the properties match.
  • For Namespace objects, values are considered equal if the uri properties of both objects match.
  • For QName objects, values are considered equal if the uri properties of both objects match and the localName properties of both objects match.
  • Variables representing objects, arrays, and functions are compared by reference. Two such variables are equal if they refer to the same object, array, or function. Two separate arrays are never considered equal, even if they have the same number of elements.
If the data types of the operands do not match, the inequality operator (!=) returns true except in the following circumstances:
  • The operands' values are undefined and null, in which case the result is true.
  • Automatic data type conversion converts the data types of String, Boolean, int, uint, and Number values to compatible types and the converted values are equal, in which case operands are considered equal.
  • One operand is of type XML with simple content (hasSimpleContent() == true), and after both operands are converted to strings with the toString() method the resulting strings match.
  • One operand is of type XMLList, and either of the following conditions is true:
    • The length property of the XMLList object is 0, and the other object is undefined.
    • The length property of the XMLList object is 1, and one element of the XMLList object matches the other operand.

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 — A value of true if the expressions are not equal, and false otherwise.

Example
How to use this example
The following example illustrates the result of the inequality (!=) operator:
trace(5 != 8); // true 
trace(5 != 5); // 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
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

See also

 instanceof Operator  
Usage

expression instanceof function

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates whether an expression's prototype chain includes the prototype object for function. The instanceof operator is included for backward compatibility with ECMAScript edition 3, and may be useful for advanced programmers who choose to use prototype-based inheritance with constructor functions instead of classes.

To check whether an object is a member of a specific data type, use the is operator.

When used with classes, the instanceof operator is similar to the is operator because a class's prototype chain includes all of its superclasses. Interfaces, however, are not included on prototype chains, so the instanceof operator always results in false when used with interfaces, whereas the is operator results in true if an object belongs to a class that implements the specified interface.

Note: The ActionScript is operator is the equivalent of the Java instanceof operator.

Operands
expression:Object — The object that contains the prototype chain to evaluate.
function:Object — A function object (or class).

Result
Boolean — Returns true if the prototype chain of expression includes the prototype object for function, and false otherwise.

Example
How to use this example
The following example creates an instance of the Sprite class named mySprite and uses the instanceof operator to test whether the prototype chain of mySprite includes the prototype objects of the Sprite and DisplayObject classes. The result is true with the Sprite class and the DisplayObject class because the prototype objects for Sprite and DisplayObject are on the prototype chain of mySprite.
var mySprite:Sprite = new Sprite();
trace(mySprite instanceof Sprite);        // true
trace(mySprite instanceof DisplayObject); // true
The following example uses the IBitmapDrawable interface to show that the instanceof operator does not work with interfaces. The is operator results in true because the DisplayObject class, which is a superclass of the Sprite class, implements the IBitmapDrawable interface.
var mySprite:Sprite = new Sprite();
trace(mySprite instanceof IBitmapDrawable); // false
trace(mySprite is IBitmapDrawable);         // true

See also

 is Operator  
Usage

expression1 is expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates whether an object is compatible with a specific data type, class, or interface. Use the is operator instead of the instanceof operator for type comparisons. You can also use the is operator to check whether an object implements an interface.

Result
Boolean — A value of true if expression1 is compatible with the data type, class, or interface specified in expression2, and false otherwise.

Example
How to use this example
The following example creates an instance of the Sprite class named mySprite and uses the is operator to test whether mySprite is an instance of the Sprite and DisplayObject classes, and whether it implements the IEventDispatcher interface.
import flash.display.*;
import flash.events.IEventDispatcher;

var mySprite:Sprite = new Sprite();
trace(mySprite is Sprite);           // true
trace(mySprite is DisplayObject);    // true
trace(mySprite is IEventDispatcher); // true

See also

< less than Operator  
Usage

expression1 < expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Compares two expressions and determines whether expression1 is less than expression2; if so, the result is true. If expression1 is greater than or equal to expression2, the result is false.

If both operands are of type String, the operands are compared using alphabetical order; all capital letters come before lowercase letters. Otherwise, operands are first converted to numbers, then compared.

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

Result
Boolean — A value of true if expression1 is less than expression2; false otherwise.

Example
How to use this example
The following examples show true and false results for both numeric and string comparisons:
trace(5 < 10); // true 
trace(2 < 2);            // false 
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 

<= less than or equal to Operator  
Usage

expression1 <= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Compares two expressions and determines whether expression1 is less than or equal to expression2; if it is, the result is true. If expression1 is greater than expression2, the result is false.

If both operands are of type String, the operands are compared using alphabetical order; all capital letters come before lowercase letters. Otherwise, operands are first converted to numbers, then compared.

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

Result
Boolean — A value of true if expression1 is less than or equal to expression2; false otherwise.

Example
How to use this 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 

// line comment delimiter Operator  
Usage

// comment

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Indicates the beginning of a script comment. Characters that appear between the comment delimiter (//) and the end-of-line character are interpreted as a comment and are ignored. Use this delimiter for single-line comments; for comments on multiple successive lines, use the /* and */ delimiters.

Operands
comment:* — Any characters.

Example
How to use this example
The following example shows a single-line comment:
// Any text following a line comment delimiter is ignored during compilation

See also

&& logical AND Operator  
Usage

expression1 && expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Returns expression1 if it is false or can be converted to false, and expression2 otherwise. Examples of values that can be converted to false are 0, NaN, null, and undefined. If you use a function call as expression2, the function is not called if expression1 evaluates to false.

If both operands are of type Boolean, the result is true only if both operands are true, as shown in the following table:

Expression

Evaluates

true && true

true

true && false

false

false && false

false

false && true

false

Operands
expression1:* — A value or expression of any type.
expression2:* — A value of expression of any type.

Result
* — A Boolean value if both operands are of type Boolean. Otherwise, the result is the value of either expression.

Example
How to use this 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 outputs "You Win the Game!" when the player's score reaches 75 or higher in three or fewer turns.
var turns:Number = 2; 
var score:Number = 77; 
if ((turns <= 3) && (score >= 75)) { 
	trace("You Win the Game!"); 
} else { 
	trace("Try Again!"); 
} 

See also

&&= logical AND assignment Operator  
Usage

expression1 &&= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

x &&= y; 
x = x && y; 

Operands
expression1:* — A value of any type.
expression2:* — A value of any type.

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

Example
How to use this example
The following example changes the myVar variable into an XML tag, unless myVar is null. The example modifies the myVar variable as long as the variable does not evaluate to false. This technique takes advantage of the fact that the logical AND (&&) operator returns the value of expression1 if expression1 evaluates to false and otherwise returns the value of expression2. If myVar already contains a value that evaluates to true, myVar is modified to resemble an XML tag. However, if myVar contains a value that evaluates to false, such as the values null, ""(empty string), and undefined, myVar remains unchanged.
var myVar:String = 'tag';
			myVar &&= "<" + myVar + "/>";
			trace (myVar); // output: <tag/>
The same effect can be achieved with an if statement, as shown in the following example:
var myVar:String = 'tag';
			if (myVar != '') {
			  myVar = "<" + myVar + "/>";
			}
			trace (myVar); // output: <tag/>
The advantage of using an if statement is that the code is easier to read, whereas the advantage of using the logical AND assignment (&&=) operator is that it you need not specify the exact default value for a given data type.

See also

! logical NOT Operator  
Usage

!expression

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
How to use this 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 outputs a string.
var happy:Boolean = false; 
if (!happy) { 
	trace("don't worry, be happy"); // don't worry, be happy 
} 
The trace statement executes because !false equals true.

See also

|| logical OR Operator  
Usage

expression1 || expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Returns expression1 if it is true or can be converted to true, and expression2 otherwise. If you use a function call as expression2, the function is not called if expression1 evaluates to true.

If both operands are of type Boolean, the result is true if either or both expressions are true; the result is false only if both expressions are false, as shown in the following table:

Expression

Evaluates

true || true

true

true || false

true

false || false

false

false || true

true

Operands
expression1:* — A value of any type.
expression2:* — A value of any type.

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

Example
How to use this 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 a:Number = 10; 
var b:Number = 250; 
var start:Boolean = false; 
if ((a > 25) || (b > 200) || (start)) { 
    trace("the logical OR test passed"); // the logical OR test passed 
} 
The message "the logical OR test passed" appears because one of the conditions in the if statement is true (b > 200).

The following example demonstrates how using a function call as the second operand 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");
}

See also

||= logical OR assignment Operator  
Usage

expression1 ||= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

x ||= y; 
x = x || y; 

Operands
expression1:* — A value of any type.
expression2:* — A value of any type.

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

Example
How to use this example
The following example assigns a default value to a previously declared variable named myVar. This technique takes advantage of the fact that the logical OR (||) operator returns the value of expression1 if expression1 evaluates to true and otherwise returns the value of expression2. If myVar already contains a value that evaluates to true, myVar is unchanged. However, if myVar contains a value that evaluates to false, such as the values null, ""(empty string), and undefined among others, myVar is assigned the value "default".
myVar ||= "default";

See also

% modulo Operator  
Usage

expression1 % expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Calculates the remainder of expression1 divided by expression2. If either operand is non-numeric, the modulo (%) operator attempts to convert it to a number.

The sign of the modulo result 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. A string that contains only numeric characters evaluates to a number.
expression2:Number — A number or expression that evaluates to a number. A string that contains only numeric characters evaluates to a number.

Result
Number — The result of the arithmetic operation.

Example
How to use this example
The following numeric example uses the modulo (%) operator:
trace(12 % 5);    // 2 
trace(4.3 % 2.1); // 0.0999999999999996 
trace(4 % 4);     // 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 assignment Operator  
Usage

expression1 %= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
How to use this example
The following example assigns the value 4 to the variable a:
var a:Number = 14; 
var b:Number = 5; 
a %= b;
trace(a); // 4 

See also

* multiplication Operator  
Usage

expression1 * expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
How to use this example
The following statement multiplies the integers 2 and 3, resulting in the integer 6:
trace(2*3); // 6 
This statement multiplies the floating-point numbers 2.0 and 3.1416, resulting in 6.2832, which is a floating-point number:
trace(2.0 * 3.1416); // 6.2832 

*= multiplication assignment Operator  
Usage

expression1 *= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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
How to use this example
The following example assigns the value 50 to the variable a:
var a:Number = 5; 
var b:Number = 10; 
trace(a *= b); // 50 
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 c and d:
var i:Number = 5; 
var c:Number = 4 - 6; 
var d:Number = i + 2; 
trace(c *= d); // -14 

See also

:: name qualifier Operator  
Usage

namespace::property
namespace::method()
namespace::xmlObject.property
namespace::xmlObject.@attribute

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Identifies the namespace of a property, a method, an XML property, or an XML attribute.

Operands
namespace:Object — The identifying namespace.
propertyName:Object — The property, method, XML property, or XML attribute to identify.

Example
How to use this example
The following example uses the :: operator to identify two methods that have the same name in two different namespaces:
public class NamespaceExample extends Sprite {
	public namespace French;
	public namespace Hawaiian;
	public function NamespaceExample() {
		trace(Hawaiian::hello()); // aloha
		trace(French::hello()); // bonjour
	}
    Hawaiian function hello():String {
        return "aloha";
    }

    French function hello():String { 
        return "bonjour";
    }
}
The following example uses the :: operator to identify XML properties with specified namespaces:
var soap:Namespace = new Namespace("http://schemas.xmlsoap.org/wsdl/soap/");
var w:Namespace = new Namespace("http://weather.example.org/forecast");
var myXML:XML = 
	<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> 
	 <soap:Body>
	  <w:forecast xmlns:w="http://weather.example.org/forecast">
	   <w:city>Quito</w:city>
	   <w:country>Ecuador</w:country>
	   <date>2006-01-14</date>
	  </w:forecast>
	  </soap:Body>
	</soap:Envelope>;
	
trace(myXML.soap::Body.w::forecast.w::city); // Quito

See also

 new Operator  
Usage

new constructor(parameters)

Runtime Versions: Flash Player 5

Instantiates a class instance. The new operator can be used with a class or a variable of type Class to create an instance of a class. The new operator is commonly used with a class object to create an instance of a class. For example, the statement new Sprite() creates an instance of the Sprite class.

The new operator can also be used to associate a class with an embedded asset, which is an external object such as an image, sound, or font that is compiled into a SWF file. Each embedded asset is represented by a unique embedded asset class. To access an embedded asset, you must use the new operator to instantiate its associated class. Subsequently, you can call the appropriate methods and properties of the embedded asset class to manipulate the embedded asset.

If you prefer to define classes with Function objects instead of the class keyword, you can use the new operator to create objects based on constructor functions. Do not confuse constructor functions with constructor methods of a class. A constructor function is a Function object that is defined with the function keyword, but that is not part of a class definition. If you use constructor functions to create objects, you must use prototype inheritance instead of class inheritance.

Operands
constructor:* — A class, a function, or a variable that holds a value of type Class.
parameters:* — One or more parameters, separated by commas.

Example
How to use this example
The following example creates the Book class and uses the new operator to create the objects book1 and book2.
class Book {
  var bName:String;
  var bPrice:Number;
  
  public function Book(nameParam:String, priceParam:Number){
    bName = nameParam;
    bPrice = priceParam;
  }
}

var book1:Book = new Book("Confederacy of Dunces", 19.95);
var book2:Book = new Book("The Floating Opera", 10.95);
trace(book1); // [object Book]
The following example uses the new operator to create an instance of the Array class with 18 elements:
var golfCourse:Array = new Array(18);

See also

{} object initializer Operator  
Usage

object = {name1 : value1, name2 : value2,... nameN : valueN}

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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:Object — The names of the properties.
value1,2,...N:Object — The corresponding values for each name property.

Result
Object — An Object object.

Example
How to use this 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 Systems, Inc.", 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 code uses the information in the previous example and produces the same result using a constructor function:
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"; 

See also

() parentheses Operator  
Usage

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

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

Usage 1: Controls the order in which the operators execute. 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 to the function that precedes the parentheses.

Operands
expression1:Object — An expression, which can include numbers, strings, variables, or text.
expression2:Object — An expression, which can include 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 arguments to the function outside the parentheses.

Example
How to use this example
Usage 1: The following statements show the use of parentheses to control the order in which expressions are executed:
trace((2 + 3) * (4 + 5)); // 45 
trace(2 + (3 * (4 + 5))); // 29
trace(2 + (3 * 4) + 5);   // 19
trace(2 + (3 * 4) + 5);   // 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)); // 23 
Usage 3: The following example shows the use of parentheses with functions:
var today:Date = new Date(); 
trace(today.getFullYear()); // outputs current year 
function traceParameter(param):void { 
  trace(param); 
} 
traceParameter(2 * 2); // 4 

See also

( ) parentheses (XML) Operator  
Usage

myXML.(expression)

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates an expression in an ECMAScript for XML (E4X) XML construct. For example, myXML.(lastName == "Smith") identifies XML elements with the name lastName and the value "Smith". The result is an XMLList object.

Operands
myXML:* — An XML or XMLList object.
expression:* — The expression defining the matching elements.

Result
XMLList — The XMLList specified by the parentheses.

Example
How to use this example
The following example shows how parentheses are used to identify elements and attributes:
var myXML:XML = 
	<employees>
		<employee id = "42">
			<firstName>Joe</firstName>
			<lastName>Smith</lastName>
		</employee>
		<employee id = "43">
			<firstName>Susan</firstName>
			<lastName>Jones</lastName>
		</employee>
		<employee id = "44">
			<firstName>Anne</firstName>
			<lastName>Smith</lastName>
		</employee>
	</employees>;
	
trace(myXML.employee.(lastName == "Smith").@id.toXMLString()); 
	// 42
	// 44
                
trace(myXML.employee.(Number(@id) > 42).@id.toXMLString()); 
	// 43
	// 44

See also

/ RegExp delimiter Operator  
Usage

/pattern/flags

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

When used before and after characters, indicates that the characters have a literal value and are considered a regular expression (RegExp), not a variable, string, or other ActionScript element. Note, however, that two sequential forward slash characters (//) indicate the beginning of a comment.

Operands
pattern:String — A sequence of one or more characters, defining the pattern of the regular expression.
flags:String — A sequence of zero or more of the following characters: g (for the global flag), i (for the ignoreCase flag), s (for the dotall flag), x (for the extended flag).

Example
How to use this example
The following example uses forward slash characters (/) to set the value of a variable of type RegExp (the i flag is set, to ignore case sensitivity when matching):
var myRegExp:RegExp = /foo-\d+/i; 
trace(myRegExp.exec("ABC Foo-32 def.")); // Foo-32 

See also

=== strict equality Operator  
Usage

expression1 === expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Tests two expressions for equality, but does not perform automatic data conversion. The result is true if both expressions, including their data types, are equal.

The strict equality (===) operator is the same as the equality (==) operator in three ways:

  • Numbers and Boolean values are compared by value and are considered equal if they have the same value.
  • String expressions are equal if they have the same number of characters and the characters are identical.
  • Variables representing objects, arrays, and functions are compared by reference. Two such variables are equal if they refer to the same object, array, or function. Two separate arrays are never considered equal, even if they have the same number of elements.
The strict equality (===) operator differs from the equality (==) operator in only two ways:
  • The strict equality operator performs automatic data conversion only for the number types (Number, int, and uint), whereas the equality operator performs automatic data conversion for all primitive data types.
  • When comparing null and undefined, the strict equality operator returns false.
The strict equality operator generates different results in ActionScript 3.0 than it did in ActionScript 2.0 in two situations involving primitive values (for example, var x:Number = 1) with primitive objects (for example, var x:Number = new Number(1)). This is because ActionScript 3.0 removes the distinction between primitive values and primitive wrapper objects.

First, comparisons between primitive values and primitive objects that contain the same value return true in ActionScript 3.0, but false in earlier versions. In earlier versions, the data type of a primitive value is either Boolean, Number, or String, whereas the data type of a primitive object is always Object rather than Boolean, Number or String. The practical effect of this difference is that the following code results in false in previous versions of ActionScript because the data types of the operands do not match, but the result is true in ActionScript 3.0 because primitive values are typed as either Boolean, Number, int, uint, or String, whether they are wrapped in an object or not.

var num1:Number = 1;
var num2:Number = new Number(1);
trace(num1 === num2); // true in ActionScript 3.0, false in ActionScript 2.0
			
Second, comparisons between two primitive objects that contain the same value result in true in ActionScript 3.0, but false in previous versions.
var num1:Number = new Number(1);
var num2:Number = new Number(1);
trace(num1 == num2);  // true in ActionScript 3.0, false in ActionScript 2.0
trace(num1 === num2); // true in ActionScript 3.0, false in ActionScript 2.0
This is because in previous versions of ActionScript, both variables belong to the data type Object, so they are compared by reference and the result is false for both the equality and strict equality operations. In ActionScript 3.0, however, both variables belong to the data type Number, so they are compared by value and the result is true for both the equality and strict equality operators.

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
How to use this example
The following example shows that strict equality (===) is the same as equality (==) when both the value and data types match:
var string1:String = "5"; 
var string2:String = "5"; 
trace(string1 == string2);  // true 
trace(string1 === string2); // true
The following example shows that the strict equality operator does not convert the String data type to Number, but the equality (==) operator does:
// The equality (==) operator converts 5 to "5", but the strict equality operator does not
var string1:String = "5"; 
var num:Number = 5; 
trace(string1 == num);  // true 
trace(string1 === num); // false 
The following example shows that the strict equality operator does not convert Boolean values to numbers, but the equality operator does:
var num:Number = 1;
var bool:Boolean = true;
trace(num == bool);  // true 
trace(num === bool); // false
The following example shows that the strict equality operator does convert int and uint data types:
var num1:Number = 1;
var num2:int = 1;
var num3:uint = 1;
trace(num1 === num2); // true
trace(num1 === num3); // true
The following example shows that the strict equality operator considers null and undefined not equal, but the equality operator considers them equal:
trace(null == undefined);  // true 
trace(null === undefined); // false 

See also

!== strict inequality Operator  
Usage

expression1 !== expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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

If expression1 is equal to expression2, and their data types are equal, the result is false.

The strict inequality (!==) operator is the same as the inequality (!=) operator in three ways:

  • Numbers and Boolean values are compared by value and are considered equal if they have the same value.
  • String expressions are equal if they have the same number of characters and the characters are identical.
  • Variables representing objects, arrays, and functions are compared by reference. Two such variables are equal if they refer to the same object, array, or function. Two separate arrays are never considered equal, even if they have the same number of elements.
The strict inequality operator differs from the inequality (!=) operator in only two ways:
  • The strict inequality (!==) operator performs automatic data conversion only for the number types, Number, int, and uint, whereas the inequality (!=) operator performs automatic data conversion for all primitive data types.
  • When comparing null and undefined, the strict inequality (!==) operator returns true.

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
How to use this 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 delimiter Operator  
Usage

 "text" 

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

When used before and after characters, indicates 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
How to use this 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.
var yourGuess:String = "Prince Edward Island"; 
submit_btn.onRelease = function() { trace(yourGuess); }; 
// Prince Edward Island

See also

- subtraction Operator  
Usage

-expression
 expression1 - expression2

Runtime Versions: Flash Player 9

Used for negating or subtracting.

Usage 1: When used for negating, the operator reverses the sign of a numerical expression.

Usage 2: When used for subtracting, the operator 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
How to use this example
Usage 1: The following statement reverses the sign of the expression 2 + 3:
trace(-(2 + 3)); // -5 
Usage 2: The following statement subtracts the integer 2 from the integer 5:
trace(5 - 2); // 3 
The result, 3, is an integer.

The following statement subtracts the floating-point number 1.5 from the floating-point number 3.25:

trace(3.25 - 1.5); // 1.75 
The result, 1.75, is a floating-point number.

-= subtraction assignment Operator  
Usage

expression1 -= expression2

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

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, the result is NaN (not a 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 — The result of the arithmetic operation.

Example
How to use this 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); // -5 
The following example shows how strings are converted to numbers:
var x:String = "5"; 
var y:String = "10"; 
x -= y; 
trace(x); // -5 

See also

: type Operator  
Usage

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

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Used for assigning a data type; 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.

Type checking always occurs at run time. However, when the compiler is set to strict mode, all types are also 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.

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

If you do not assign a data type, the variable, function return value, or function parameter is considered untyped, which means that the value can be of any data type. If you wish to make clear your intent to use an untyped value, you can use the asterisk (~~) character as the type annotation. When used as a type annotation, the asterisk character is equivalent to leaving a variable, function return type, or function parameter untyped.

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

Example
How to use this 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 return type by defining a function named randomInt() that specifies its return type as int:
function randomInt(integer:int):int { 
	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

 typeof Operator  
Usage

typeof expression

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Evaluates expression and returns a string specifying the expression's data type. The result is limited to six possible string values: boolean, function, number, object, string, and xml. If you apply this operator to an instance of a user-defined class, the result is the string object. The typeof operator is included for backward compatibility. Use the is operator to check type compatibility.

Operands
expression:Object — An object to evaluate.

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

Array

object

Boolean

boolean

Function

function

int

number

Number

number

Object

object

String

string

uint

number

XML

xml

XMLList

xml


Example
How to use this example
The following example shows the result of using typeof on various objects and values.
trace(typeof Array); // object
trace(typeof Date);  // object
trace(typeof 3);     // number
The following example shows that in ActionScript 3.0, the data type of a primitive object is the same whether you assign a literal value or use the new operator to create an object. This differs from previous versions of ActionScript in which the typeof operator returns object for variable b:
var a:String = "sample";
var b:String = new String("sample");
trace(typeof a); // string
trace(typeof b); // string 

See also

 void Operator  
Usage

void expression

Runtime Versions: Flash Player 9

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

Operands
expression:Object — An expression to be evaluated.

Result
* — The value undefined.
< > XML literal tag delimiter Operator  
Usage

 myXML= <{tagName} {attributeName} = {attributeValue}>{content}

Language Version: ActionScript 3.0
Runtime Versions: Flash Player 9

Defines an XML tag in an XML literal. Use the forward slash / to define the closing tag.

Operands
myXML:* — An XML or XMLList object.
tagName:* — An expression that evaluates to the name of an XML tag.
attributeName:* — An expression that evaluates to the name of an XML attribute.
attributeValue:* — An expression that evaluates to the value of an XML attribute.
content:* — An expression that evaluates to the contents of an XML tag.

Example
How to use this example
The following example shows how to use the < and > operators when defining an XML literal:
var x:XML = <item id= "324">cola</item>; 

See also