http://help.adobe.com/en_US/as2/reference/flashlite/WS5b3ccc516d4fbf351e63e3d118d1ff2a53-7dc3.html
http://help.adobe.com/en_US/as2/reference/flashlite/WS5b3ccc516d4fbf351e63e3d118cd9b5f6e-7a5e.html
http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fd1.html#WS5b3ccc516d4fbf351e63e3d118a9b90204-7f62
http://www.adobe.com/devnet/flash/articles/debugging_actionscript.html
https://www.youtube.com/watch?v=ihB9IH8S6Fs
https://www.youtube.com/watch?v=ws_bB8TQvEI
https://www.google.co.uk/search?espv=2&rlz=1C1GNAM_en-GBGB681GB681&biw=1280&bih=699&tbm=isch&sa=1&q=FLASH+AS2+OPERATORS&oq=FLASH+AS2+OPERATORS&gs_l=img.3...2393.3358.0.3637.4.4.0.0.0.0.56.200.4.4.0....0...1c.1.64.img..0.1.55.6elW5Y8E9Sc#imgrc=0uZj-qXLHUkInM%3A
Operators
Symbolic operators are characters that specify how to combine, compare, or modify the values of an expression.
Operators summary
Operator
|
Description
|
---|---|
+ (addition)
|
Adds numeric expressions or concatenates (combines) strings.
|
+= (addition assignment)
|
Assigns expression1 the value of expression1 + expression2.
|
[] (array access)
|
Initializes a new array or multidimensional array with the specified elements (a0, and so on), or accesses elements in an array.
|
= (assignment)
|
Assigns the value of expression2 (the parameter on the right) to the variable, array element, or property in expression1.
|
& (bitwise AND)
|
Converts expression1 and expression2 to 32-bit unsigned integers, and performs a Boolean AND operation on each bit of the integer parameters.
|
Assigns expression1 the value of expression1& expression2.
| |
<< (bitwise left shift)
|
Converts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the left by the number of places specified by the integer resulting from the conversion of expression2.
|
This operator performs a bitwise left shift (<<) operation and stores the contents as a result in expression1.
| |
~ (bitwise NOT)
|
Also known as the one's complement operator or the bitwise complement operator.
|
| (bitwise OR)
|
Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits of either expression1 orexpression2 are 1.
|
Assigns expression1 the value of expression1 | expression2.
| |
>> (bitwise right shift)
|
Converts expression1 and expression2 to 32-bit integers, and shifts all the bits in expression1 to the right by the number of places specified by the integer that results from the conversion of expression2.
|
This operator performs a bitwise right-shift operation and stores the contents as a result in expression1.
| |
The same as the bitwise right shift (>> ) operator except that it does not preserve the sign of the original expression because the bits on the left are always filled with 0. Floating-point numbers are converted to integers by discarding any digits after the decimal point.
| |
Performs an unsigned bitwise right-shift operation and stores the contents as a result in expression1.
| |
^ (bitwise XOR)
|
Converts expression1 and expression2 to 32-bit unsigned integers, and returns a 1 in each bit position where the corresponding bits in expression1 or expression2, but not both, are 1.
|
Assigns expression1 the value of expression1 ^ expression2.
| |
Indicates one or more lines of script comments.
| |
, (comma)
|
Evaluates expression1, then expression2, and so on.
|
add (concatenation (strings))
|
Deprecated since Flash Player 5. Adobe recommends you use the addition (+) operator when creating content for Flash Player 5 or later.
Note: Flash Lite 2.0 also deprecates the add operator in favor of the addition (+) operator.
Concatenates two or more strings.
|
?: (conditional)
|
Instructs Flash to evaluate expression1, and if the value of expression1 is true, it returns the value of expression2; otherwise it returns the value of expression3.
|
-- (decrement)
|
A pre-decrement and post-decrement unary operator that subtracts 1 from the expression.
|
/ (division)
|
Divides expression1 by expression2.
|
/= (division assignment)
|
Assigns expression1 the value of expression1 / expression2.
|
. (dot)
|
Used to navigate movie clip hierarchies to access nested (child) movie clips, variables, or properties.
|
== (equality)
|
Tests two expressions for equality.
|
eq (equality (strings))
|
Deprecated since Flash Player 5. This operator was deprecated in favor of the == (equality) operator.
Returns true if the string representation of expression1 is equal to the string representation of expression2, false otherwise.
|
> (greater than)
|
Compares two expressions and determines whether expression1 is greater than expression2; if it is, the operator returns true.
|
Deprecated since Flash Player 5. This operator was deprecated in favor of the > (greater than) operator.
Compares the string representation of expression1 with the string representation of expression2 and returns true if expression1 is greater than expression2, falseotherwise.
| |
Compares two expressions and determines whether expression1 is greater than or equal to expression2 (true) or expression1 is less than expression2 (false).
| |
Deprecated since Flash Player 5. This operator was deprecated in favor of the >= (greater than or equal to) operator.
Returns true if expression1 is greater than or equal to expression2, false otherwise.
| |
++ (increment)
|
A pre-increment and post-increment unary operator that adds 1 to expression .
|
!= (inequality)
|
Tests for the exact opposite of the equality (== ) operator.
|
<> (inequality)
|
Deprecated since Flash Player 5. This operator has been deprecated. Adobe recommends that you use the != (inequality) operator.
Tests for the exact opposite of the equality (==) operator.
|
Tests whether object is an instance of classConstructor or a subclass of classConstructor.
| |
< (less than)
|
Compares two expressions and determines whether expression1 is less than expression2; if so, the operator returns true.
|
lt (less than (strings))
|
Deprecated since Flash Player 5. This operator was deprecated in favor of the < (less than) operator.
Returns true if expression1 is less than expression2, false otherwise.
|
Compares two expressions and determines whether expression1 is less than or equal to expression2; if it is, the operator returns true.
| |
Deprecated since Flash Player 5. This operator was deprecated in Flash 5 in favor of the <= (less than or equal to) operator.
Returns true if expression1 is less than or equal to expression2, false otherwise.
| |
Indicates the beginning of a script comment.
| |
&& (logical AND)
|
Performs a Boolean operation on the values of one or both of the expressions.
|
and (logical AND)
|
Deprecated since Flash Player 5. Adobe recommends that you use the logical AND (&&) operator.
Performs a logical AND (&&) operation in Flash Player 4.
|
! (logical NOT)
|
Inverts the Boolean value of a variable or expression.
|
not (logical NOT)
|
Deprecated since Flash Player 5. This operator was deprecated in favor of the ! (logical NOT) operator.
Performs a logical NOT (!) operation in Flash Player 4.
|
|| (logical OR)
|
Evaluates expression1 (the expression on the left side of the operator) and returns true if the expression evaluates to true.
|
or (logical OR)
|
Deprecated since Flash Player 5. This operator was deprecated in favor of the || (logical OR) operator.
Evaluates condition1 and condition2, and if either expression is true, the whole expression is true.
|
% (modulo)
|
Calculates the remainder of expression1 divided by expression2.
|
%= (modulo assignment)
|
Assigns expression1 the value of expression1 % expression2.
|
* (multiplication)
|
Multiplies two numerical expressions.
|
Assigns expression1 the value of expression1 * expression2.
| |
Creates a new, initially anonymous, object and calls the function identified by the constructor parameter.
| |
ne (not equal (strings))
|
Deprecated since Flash Player 5. This operator was deprecated in favor of the != (inequality) operator.
Returns true if expression1 is not equal to expression2; false otherwise.
|
{} (object initializer)
|
Creates a new object and initializes it with the specified name and value property pairs.
|
() (parentheses)
|
Performs a grouping operation on one or more parameters, performs sequential evaluation of expressions, or surrounds one or more parameters and passes them as parameters to a function outside the parentheses.
|
=== (strict equality)
|
Tests two expressions for equality; the strict equality (===) operator performs in the same way as the equality (==) operator, except that data types are not converted.
|
!== (strict inequality)
|
Tests for the exact opposite of the strict equality (===) operator.
|
" (string delimiter)
|
When used before and after characters, quotation marks (") indicate that the characters have a literal value and are considered a string, not a variable, numerical value, or other ActionScript element.
|
- (subtraction)
|
Used for negating or subtracting.
|
Assigns expression1 the value of expression1 - expression2.
| |
: (type)
|
Used for strict data typing; this operator specifies the variable type, function return type, or function parameter type.
|
The typeof operator evaluate the expression and returns a string specifying whether the expression is a String, MovieClip, Object, Function, Number, or Booleanvalue.
| |
The void operator evaluates an expression and then discards its value, returning undefined.
|
Operators
Operators are special functions that take one or more operands and return a value. An operand is a value—usually a literal, a variable, or an expression—that an operator uses as input. For example, in the following code, the addition ( + ) and multiplication ( * ) operators are used with three literal operands (2, 3 , and 4 )to return a value. This value is then used by the assignment ( = ) operator to assign the returned value, 14, to the variable sumNumber .
var sumNumber:uint = 2 + 3 * 4; // uint = 14
Operators can be unary, binary, or ternary. A unary operator takes one operand. For example, the increment ( ++ ) operator is a unary operator, because it takes only one operand. A binary operator takes two operands. For example, the division ( / ) operator takes two operands. A ternary operator takes three operands. For example, the conditional ( ?: ) operator takes three operands.
Some operators are overloaded , which means that they behave differently depending on the type or quantity of operands passed to them. The addition ( + ) operator is an example of an overloaded operator that behaves differently depending on the data type of the operands. If both operands are numbers, the addition operator returns the sum of the values. If both operands are strings, the addition operator returns the concatenation of the two operands. The following example code shows how the operator behaves differently depending on the operands:
trace(5 + 5); // 10 trace("5" + "5"); // 55
Operators can also behave differently based on the number of operands supplied. The subtraction ( - ) operator is both a unary and binary operator. When supplied with only one operand, the subtraction operator negates the operand and returns the result. When supplied with two operands, the subtraction operator returns the difference between the operands. The following example shows the subtraction operator used first as a unary operator, and then as a binary operator.
trace(-3); // -3 trace(7 - 2); // 5
Operator precedence and associativity
Operator precedence and associativity determine the order in which operators are processed. Although it may seem natural to those familiar with arithmetic that the compiler processes the multiplication ( * ) operator before the addition ( + ) operator, the compiler needs explicit instructions about which operators to process first. Such instructions are collectively referred to as operator precedence . ActionScript defines a default operator precedence that you can alter using the parentheses ( ()) operator. For example, the following code alters the default precedence in the previous example to force the compiler to process the addition operator before the multiplication operator:
var sumNumber:uint = (2 + 3) * 4; // uint == 20
You may encounter situations in which two or more operators of the same precedence appear in the same expression. In these cases, the compiler uses the rules ofassociativity to determine which operator to process first. All of the binary operators, except the assignment operators, are left-associative , which means that operators on the left are processed before operators on the right. The assignment operators and the conditional ( ?: ) operator are right-associative , which means that the operators on the right are processed before operators on the left.
For example, consider the less-than ( < ) and greater-than ( > ) operators, which have the same precedence. If both operators are used in the same expression, the operator on the left is processed first because both operators are left-associative. This means that the following two statements produce the same output:
trace(3 > 2 < 1); // false trace((3 > 2) < 1); // false
The greater-than operator is processed first, which results in a value of true , because the operand 3 is greater than the operand 2. The value true is then passed to the less-than operator along with the operand 1. The following code represents this intermediate state:
trace((true) < 1);
The less-than operator converts the value true to the numeric value 1 and compares that numeric value to the second operand 1 to return the value false (the value 1 is not less than 1).
trace(1 < 1); // false
You can alter the default left associativity with the parentheses operator. You can instruct the compiler to process the less-than operator first by enclosing that operator and its operands in parentheses. The following example uses the parentheses operator to produce a different output using the same numbers as the previous example:
trace(3 > (2 < 1)); // true
The less-than operator is processed first, which results in a value of false because the operand 2 is not less than the operand 1. The value false is then passed to the greater-than operator along with the operand 3. The following code represents this intermediate state:
trace(3 > (false));
The greater-than operator converts the value false to the numeric value 0 and compares that numeric value to the other operand 3 to return true (the value 3 is greater than 0).
trace(3 > 0); // true
The following table lists the operators for ActionScript 3.0 in order of decreasing precedence. Each row of the table contains operators of the same precedence. Each row of operators has higher precedence than the row appearing below it in the table.
Group
|
Operators
|
---|---|
Primary
| [] {x:y} () f(x) new x.y x[y] <></> @ :: .. |
Postfix
| x++ x-- |
Unary
| ++x --x + - ~ ! delete typeof void |
Multiplicative
| * / % |
Additive
| + - |
Bitwise shift
| << >> >>> |
Relational
| < > <= >= as in instanceof is |
Equality
| == != === !== |
Bitwise AND
| & |
Bitwise XOR
| ^ |
Bitwise OR
| | |
Logical AND
| && |
Logical OR
| || |
Conditional
| ?: |
Assignment
| = *= /= %= += -= <<= >>= >>>= &= ^= |= |
Comma
| , |
Primary operators
The primary operators include those used for creating Array and Object literals, grouping expressions, calling functions, instantiating class instances, and accessing properties.
All the primary operators, as listed in the following table, have equal precedence. Operators that are part of the E4X specification are indicated by the (E4X) notation.
Operator
|
Operation performed
|
---|---|
[] |
Initializes an array
|
{x:y} |
Initializes an object
|
() |
Groups expressions
|
f(x) |
Calls a function
|
new |
Calls a constructor
|
x.y x[y] |
Accesses a property
|
<></> |
Initializes an XMLList object (E4X)
|
@ |
Accesses an attribute (E4X)
|
:: |
Qualifies a name (E4X)
|
.. |
Accesses a descendant XML element (E4X)
|
Postfix operators
The postfix operators take one operator and either increment or decrement the value. Although these operators are unary operators, they are classified separately from the rest of the unary operators because of their higher precedence and special behavior. When a postfix operator is used as part of a larger expression, the expression’s value is returned before the postfix operator is processed. For example, the following code shows how the value of the expression xNum++ is returned before the value is incremented:
var xNum:Number = 0; trace(xNum++); // 0 trace(xNum); // 1
All the postfix operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
++ |
Increments (postfix)
|
-- |
Decrements (postfix)
|
Unary operators
The unary operators take one operand. The increment ( ++ ) and decrement ( -- ) operators in this group are prefix operators , which means that they appear before the operand in an expression. The prefix operators differ from their postfix counterparts in that the increment or decrement operation is completed before the value of the overall expression is returned. For example, the following code shows how the value of the expression ++xNum is returned after the value is incremented:
var xNum:Number = 0; trace(++xNum); // 1 trace(xNum); // 1
All the unary operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
++ |
Increments (prefix)
|
-- |
Decrements (prefix)
|
+ |
Unary +
|
- |
Unary - (negation)
|
! |
Logical NOT
|
~ |
Bitwise NOT
|
delete |
Deletes a property
|
typeof |
Returns type information
|
void |
Returns undefined value
|
Multiplicative operators
The multiplicative operators take two operands and perform multiplication, division, or modulo calculations.
All the multiplicative operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
* |
Multiplication
|
/ |
Division
|
% |
Modulo
|
Additive operators
The additive operators take two operands and perform addition or subtraction calculations. All the additive operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
+ |
Addition
|
- |
Subtraction
|
Bitwise shift operators
The bitwise shift operators take two operands and shift the bits of the first operand to the extent specified by the second operand. All the bitwise shift operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
<< |
Bitwise left shift
|
>> |
Bitwise right shift
|
>>> |
Bitwise unsigned right shift
|
Relational operators
The relational operators take two operands, compare their values, and return a Boolean value. All the relational operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
< |
Less than
|
> |
Greater than
|
<= |
Less than or equal to
|
>= |
Greater than or equal to
|
as |
Checks data type
|
in |
Checks for object properties
|
instanceof |
Checks prototype chain
|
is |
Checks data type
|
Equality operators
The equality operators take two operands, compare their values, and return a Boolean value. All the equality operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
== |
Equality
|
!= |
Inequality
|
=== |
Strict equality
|
!== |
Strict inequality
|
Bitwise logical operators
The bitwise logical operators take two operands and perform bit-level logical operations. The bitwise logical operators differ in precedence and are listed in the following table in order of decreasing precedence:
Operator
|
Operation performed
|
---|---|
& |
Bitwise AND
|
^ |
Bitwise XOR
|
| |
Bitwise OR
|
Logical operators
The logical operators take two operands and return a Boolean result. The logical operators differ in precedence and are listed in the following table in order of decreasing precedence:
Operator
|
Operation performed
|
---|---|
&& |
Logical AND
|
|| |
Logical OR
|
Conditional operator
The conditional operator is a ternary operator, which means that it takes three operands. The conditional operator is a shorthand method of applying the if..elseconditional statement.
Operator
|
Operation performed
|
---|---|
?: |
Conditional
|
Assignment operators
The assignment operators take two operands and assign a value to one operand, based on the value of the other operand. All the assignment operators, as listed in the following table, have equal precedence:
Operator
|
Operation performed
|
---|---|
= |
Assignment
|
*= |
Multiplication assignment
|
/= |
Division assignment
|
%= |
Modulo assignment
|
+= |
Addition assignment
|
-= |
Subtraction assignment
|
<<= |
Bitwise left shift assignment
|
>>= |
Bitwise right shift assignment
|
>>>= |
Bitwise unsigned right shift assignment
|
&= |
Bitwise AND assignment
|
^= |
Bitwise XOR assignment
|
|= |
Bitwise OR assignment
|
EmoticonEmoticon