Home Computer programming AS3 switch/case statement syntax

AS3 switch/case statement syntax

0
1034

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")
}

NO COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here

error: Content is protected !!