actionscript switch statement


/ Published in: ActionScript
Save to your folder(s)

shows the basic structure of a switch statement. switches are useful when you want to respond to a series of possible values that a variable might have, without having to write a shitload of "if(blah blah){do blah}" code which, as we know soon ends up as curly bracket spaghetti!


Copy this code and paste it in your HTML
  1. /* |||||||||||||| SWITCH STATEMENT ||||||||||||||||||
  2.  
  3. switches are useful when you want to respond to a series of possible values that a variable might have, without having to write a shitload of "if(blah blah){do blah}" code which, as we know soon ends up as curly bracket spaghetti. for example, if you had a variable called 'sizeofarse' which stored the girth of someone's buttocks and you wanted to respond accordingly you could use a switch, like so:
  4.  
  5. switch(sizeofarse)
  6. {
  7. case "tiny":
  8. // do some tiny arse related stuff
  9. break;
  10.  
  11. case "medium":
  12. // do some medium-sized arse related stuff
  13. break;
  14.  
  15. case "huge":
  16. // do some huge arse related stuff
  17. break;
  18.  
  19. }
  20.  
  21. OK - got that. now for the real thing!
  22. ||||||||||||||||||||||||||||||||||||||||||||||||||| */
  23.  
  24.  
  25.  
  26. //begin switch
  27. switch()
  28. {
  29. // all possible 'cases' go below here
  30.  
  31. //first case
  32. case "":
  33. // do first case stuff
  34. break;
  35.  
  36. // second case
  37. case "":
  38. // do second case stuff
  39. break;
  40.  
  41. // etc... etc... add as many more 'cases' as needed
  42.  
  43. // all possible 'cases' go above here
  44. }
  45. // end switch

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.