Returns
Both forms invoke a function. The function may return any value.
Parameters
- The method to invoke in the superclass.
method:Function
- Optional parameters that are passed to the superclass version of the method (syntax 1)
argN
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
statement tests a condition and executes statements if the condition returns a value
switch
of
. All switch statements should include a default case. The default case should include a
true
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
- Any expression.
expression
Example
In the following example, if the
evaluates to
, the
A
trace
evaluates to
, the
a
trace()
expression matches the
statement that follows the
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" :
228
ActionScript language elements
String.fromCharCode(Key.getAscii())
() statement that follows
statement that follows
String.fromCharCode(Key.getAscii())
keyword executes.
default
executes; if the parameter
case "A"
executes; and so on. If no
case "a"
parameter, the
statement, the
if
parameter
case
trace()
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?