The switch statement is useful when performing the same action for one of several matching possibilities. : Switch : Statement Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Statement » Switch »

 

The switch statement is useful when performing the same action for one of several matching possibilities.


 


package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){


        var animalName:String = "dove";
        
        switch (animalName) {
          case "turtle":
          case "iguana":
            trace("Yay! You named a reptile.");
            break;
          case "dove":
          case "cardinal":
            trace("Sorry, you specified a bird, not a reptile.");
            break;
          default:
            trace("Sorry, try again.");
        }
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Statement
» Switch