?: (conditional)
Top  Previous  Next


SWiSH Player Support
SWF4 or later - Supported Internally

Syntax
expression1 ? expression2 : expression3

Arguments
expression1: An expression that evaluates to a boolean value, usually a comparison expression, such as x < 5.
expression2, expression3: Values of any type.

Returns
expression2 if expression1 is true, expression3 if expression1 is false.

Description
Operator; instructs the Flash Player to evaluate expression1, and if the value of expression1 is true, it returns the value of expression2; otherwise it returns the value of expression3.

Sample
The following statement assigns the value of variable x to variable z because expression1 evaluates to true:
x = 5
;
y = 10
;
z = (x < 6
) ? x: y; // z assigned the value of x as (x<6) is true.
trace (z);
// returns 5