+= (addition assignment) 253
Usage 3: This statement adds the integers 2 and 3 and displays the resulting integer, 5, in the
Output panel:
trace (2 + 3);
This statement adds the floating-point numbers 2.5 and 3.25 and displays the result, 5.75, a
floating-point number, in the Output panel:
trace (2.5 + 3.25);
See also
_accProps
+= (addition assignment)
Availability
Flash Player 4.
Usage
expression1 += expression2
Parameters
expression1,expression2
A number or string.
Returns
Nothing.
Description
Operator (arithmetic compound assignment); assigns expression1 the value of expression1 +
expression2
. For example, the following two statements have the same result:
x += y;
x = x + y;
This operator also performs string concatenation. All the rules of the addition operator (+) apply
to the addition assignment
(+=) operator.
Example
The following example shows a numeric use of the += operator.
x = 5;
y = 10;
x += y;
trace(x);
//x returns 15
This example uses the
+= operator with a string expression and sends "My name is Gilbert" to the
Output panel.
x = "My name is "
x += "Gilbert"
trace (x)
// returns "My name is Gilbert"
See also
+ (addition)