Tuesday, November 19, 2024
HomeComputer programmingAS3 switch/case statement syntax

AS3 switch/case statement syntax

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

David Kirk
David Kirk
David Kirk is one of the original founders of tech-recipes and is currently serving as editor-in-chief. Not only has he been crafting tutorials for over ten years, but in his other life he also enjoys taking care of critically ill patients as an ICU physician.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

LATEST REVIEWS

Recent Comments

error: Content is protected !!