+ (addition)
Availability
Flash Player 4; Flash Player 5.In Flash 5 and later,
concatenator depending on the data type of the parameter. In Flash 4,
operator. Flash 4 files that are brought into the Flash 5 or later authoring environment undergo a
conversion process to maintain data type integrity. The following example illustrates the
conversion of a Flash 4 file containing a numeric quality comparison:
Flash 4 file:
x + y
Converted Flash 5 or later file:
Number(x) + Number(y)
Usage
expression1 + expression2
Parameters
expression1,expression2
Returns
A string, integer, or floating-point number.
Description
Operator; adds numeric expressions or concatenates (combines) strings. If one expression is a
string, all other expressions are converted to strings and concatenated.
If both expressions are integers, the sum is an integer; if either or both expressions are floating-
point numbers, the sum is a floating-point number.
For more information, see "Operator precedence and associativity" in Using ActionScript in Flash.
Example
Usage 1: The following example concatenates two strings and displays the result in the
Output panel.
var name:String = "Cola";
var instrument:String = "Drums";
trace(name+" plays "+instrument);
Usage 2: 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 resulting floating-
point number, 5.75, in the Output panel
trace(2.5+3.25);
70
Chapter 2: ActionScript Language Reference
A number or string.
// output: 5
// output: 5.75
is either a numeric operator or a string
+
// output: Cola plays Drums
is only a numeric
+
Need help?
Do you have a question about the FLASH MX 2004-ACTIONSCRIPT LANGUAGE and is the answer not in the manual?