This howto describes the basic usage of switch/case statements in actionscript.
Case/Switch statements are frequently used for complex if/then coding. Here is a basic example of how to build these constructs.
switch (example_string)
{
case "a":
trace ("a was selected");
break;
case "b":
trace ("b was selected");
break;
default:
trace ("Neither a or b was selected")
}
By leaving out the break, you can create the same action for several different case statements…
switch (example_string)
{
case "a":
case "b":
trace ("either a or b was selected");
break;
default:
trace ("Neither a or b was selected")
}