In Flash ActionScripting, operators playa major role. They are ba cally special functions that work on one or more operands a return a suitable value. The value may be a literal, a variable or expression that is used as an input by the operator.
For instance, take the following code. Here the addition (+) a the multiplication (0) operator are used with three literal operan (2,3,4) to return a value which is further used by the assignme operator to assign the returned value to the variable sumNumber.
var sumNumber:uint = 2 + 3 * 4; // uint = 14
Various types of operators are used in Flash ActionScriptin The most common operators that are used include the una binary or the ternary operator. In the case of the unary operat one operand is taken (the increment or ++ operator) while in the
case of the binary operator, two operands are need (such as the division operator). On the other hand, the ternary operator works on three operands (e.g. the conditional operator). Besides these, there are operators in ActionScnpt whlCh are overloaded i.e they behave differently depending on the type or number of operands passed to them. The most common example of an overloaded operator is the addition operator. The addItIOn operator returns the concatenation of two operands when both the operands are strings. This is illustrated below.
trace(5 + 5); // 10
trace ("5" + "5"); // "55"
Besides these operators, other commonly used operators that are used in Flash ActionScripting are:
•Primary operators
•Postfix operators
•Unary operators
•Multiplicative operators
•Bitwise shift operators
•Relational operators
•Equality operators
•Bitwise logical operators
•Logical operators
•Conditional operator
![]()



Reply With Quote
Copyright Techfuels
Bookmarks