EasyManua.ls Logo

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE - Switch Statement

MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
1378 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
228 ActionScript language elements
Returns
Both forms invoke a function. The function may return any value.
Parameters
method:Function - The method to invoke in the superclass.
argN - Optional parameters that are passed to the superclass version of the method (syntax 1)
or to the constructor function of the superclass (syntax 2).
switch statement
switch (expression){
caseClause:
[defaultClause:]
}
Creates a branching structure for ActionScript statements. As with the if statement, the
switch statement tests a condition and executes statements if the condition returns a value
of
true. All switch statements should include a default case. The default case should include a
break statement that prevents a fall-through error if another case is added later. When a case
falls through, it doesn't have a break statement.
Availability: ActionScript 1.0; Flash Player 4
Parameters
expression - Any expression.
Example
In the following example, if the
String.fromCharCode(Key.getAscii()) parameter
evaluates to
A, the trace() statement that follows case "A" executes; if the parameter
evaluates to
a, the trace() statement that follows case "a"executes; and so on. If no case
expression matches the
String.fromCharCode(Key.getAscii()) parameter, the trace()
statement that follows the
default keyword executes.
var listenerObj:Object = new Object();
listenerObj.onKeyDown = function() {
switch (String.fromCharCode(Key.getAscii())) {
case "A" :
trace("you pressed A");
break;
case "a" :
trace("you pressed a");
break;
case "E" :
case "e" :

Table of Contents

Related product manuals