Flashadvisor logo
:: Desktop Shortcut
:: Flash Help
Advices from Experts

 Submit Here! · Link to Us · Newsletter · Tell a Friend ·

      Add Tutorial |

 

Advertise here










 

Google

Search WWW   
FlashAdvisor.com

 Home > Tutorials  > ActionScript

Flash Actionscript Programming Basics

Author: steve happ | Email
Website : www.video-animation.com


Advertisement


Switch (AS 2.0 only)



A switch statement is an alternative to complex nested if .. else statements


switch(variable){
case 1:
//Statement1;
break;
case 2:
//Statement2
break;
default:
//statement3;
break;
}

The variable to be evaluated is inserted into the switch argument.
If the first variable's value is 1 then statement1 is evaluated.
A break statement is inserted after it so that the switch statement is terminated.
The default label is the condition for "everything else".

var tester:Number;
tester = random(3);
switch (tester) {
case 1 :
trace("tester = 1");
break;
case 2 :
trace("tester = 2");
break;
case 3 :
trace("tester = 3");
break;
default :
trace("Out of range");
break;
}



| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 |

Rate This Tutorial :
We hope the information helped you. If you have any questions or comments, please don't hesitate to post them on the Forums section
Submit your Tutorial at Click Here
  

Home | About Us | Contact Us | Feedback | Advertise with us

Best viewed in 800x600 resolution with Internet Explorer.

Site Developed and Hosted by  ethicsolutions.com
All rights reserved with FlashAdvisor

Flash is a registered trademark of Adobe Systems, Inc.

23 users online