User Guide
25
CHAPTER 2
ActionScript Language Reference
–– (decrement)
Availability
Flash Player 4.
Usage
––expression
expression––
Parameters
expression
A number or a variable that evaluates to a number.
Returns
A number.
Description
Operator (arithmetic); a pre-decrement and post-decrement unary operator that subtracts 1 from
the
expression. The expression can be a variable, element in an array, or property of an object.
The pre-decrement form of the operator (
––expression) subtracts 1 from expression and
returns the result. The post-decrement form of the operator (
expression––) subtracts 1 from the
expression and returns the initial value of expression (the value prior to the subtraction). For
more information, see “Operator precedence and associativity” in Using ActionScript in Flash.
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