Operators > + (addition)

+ (addition)

Syntax

expression1 + expression2

Arguments

expression1,expression2 Integers, numbers, floating-point numbers, or strings.

Description

Operator; adds numeric expressions or concatenates 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.

Player

Flash 4; Flash 5 or later. In Flash 5, + is a numeric operator or string concatenator depending on the data type of the argument. In Flash 4, + is only a numeric operator. Flash 4 files brought into the Flash 5 authoring environment undergo a conversion process to maintain data type integrity. The first example below illustrates the conversion process.

Example

The following illustrates the conversion of a Flash 4 file containing a numeric quality comparison:

Flash 4 file:

x + y

Converted Flash 5 file:

Number(x) + Number(y)

This statement adds the integers 2 and 3 and then displays the resulting integer, 5, in the Output window:

trace (2 + 3);

This statement adds the floating-point numbers 2.5 and 3.25 and displays the result, 5.7500, a floating-point number, in the Output window:

trace (2.5 + 3.25);

This statement concatenates two strings and displays the result, "today is my birthday," in the Output window:

"today is my" + "birthday"

See also

add