default statement

default: statements

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.

Availability: ActionScript 1.0; Flash Player 6

Parameters

statements:String - Any statements.

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 statement


Flash CS3