User Guide
278 Chapter 2: ActionScript Language Reference
default
Availability
Flash Player 6.
Usage
default: statements
Parameters
statements
Any statements.
Returns
Nothing.
Description
Statement; defines the default case for a switch statement. The statements execute if the
expression parameter of the switch statement doesn’t equal (using the strict equality [===]
operation) any of the
expression parameters that follow the case keywords for a given switch
statement.
A
switch is not required to have a default case statement. A default case statement does not
have to be last in the list. If you use a
default statement outside a switch statement, it produces
an error and the script doesn’t compile.
Example
In the following example, the expression A does not equal the expressions B or D, so the
statement following the
default keyword is run and the trace() statement is sent to the Output
panel.
var dayOfWeek:Number = new Date().getDay();
switch (dayOfWeek) {
case 1 :
trace("Monday");
break;
case 2 :
trace("Tuesday");
break;
case 3 :
trace("Wednesday");
break;
case 4 :
trace("Thursday");
break;
case 5 :
trace("Friday");
break;
default :
trace("Weekend");
}
See also
switch, case, break
CHAPTER 2
ActionScript Language Reference