186
Syntax and Language Fundamentals
About postfix operators
The postfix operators take one operator and either increment or decrement the operator’s
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. For
information on unary operators, see
“About unary operators” on page 186
.
When you use a postfix operator 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
When you trace this code, the text in the Output panel reads:
0
1
The operators in this table have equal precedence:
About unary operators
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.
They can also appear after the operand, in which case they are
postfix
operators. For
information on postfix operators, see
“About postfix operators” on page 186
.
The prefix operators differ from the postfix counterparts because the increment or decrement
operation completes 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
Operator
Operation performed
++
Increment (postfix)
--
Decrement (postfix)
Summary of Contents for FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Page 1: ...Learning ActionScript 2 0 in Flash...
Page 8: ...8 Contents...
Page 18: ...18 Introduction...
Page 30: ...30 What s New in Flash 8 ActionScript...
Page 66: ...66 Writing and Editing ActionScript 2 0...
Page 328: ...328 Interfaces...
Page 350: ...350 Handling Events...
Page 590: ...590 Creating Interaction with ActionScript...
Page 710: ...710 Understanding Security...
Page 730: ...730 Debugging Applications...
Page 780: ...780 Deprecated Flash 4 operators...
Page 830: ...830 Index...