SWiSH Player Support
SWF4 or later - Supported Internally
Syntax
if(condition) {
statement(s);
}
or
iff (condition) {
statements(s)
} else {
statements(s)
}
or
if (condition) {
statements(s)
} else if (condition) {
statements(s)
} else {
statements(s)
}
Arguments
condition: An expression that evaluates to true or false.
statement(s): The instructions to execute if or when the condition evaluates to true.
Returns
Nothing.
Description
Action: Evaluates a condition. If condition evaluates to true, then statements(s) within {} are executed.
Sample
onLoad() {
a = 2;
b = 1;
if (a > b) {
trace("a > b");
}
// "a > b" will be displayed in 'Debug' window. If a < b, nothing will be displayed.
onLoad() {
a = 5;
b = 3;
if (a == b) {
trace(a add " and " add b add " are equal);
} else {
trace(a add " and " add b add " are not equal);
}
}
// displays "5 and 3 are not equal" in the debug window
onLoad() {
a = 10;
b = 5;
c = 5;
if ((a+b) == c) {
trace("Values are equal");
} else if ((a - b) == c) {
trace(a add " minus " add b add " is equal to " add c);
} else {
trace(a add " + " add b add " is not equal to " add c);
}
}
// displays "10 minus 5 is equal to 5" in the debug window
See Also
else and else if.