Return to Snippet

Revision: 14539
at June 6, 2009 06:26 by stiobhart


Initial Code
/* |||||||||||||| 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. 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:

switch(sizeofarse)
{
	case "tiny":
	// do some tiny arse related stuff
	break;
	
	case "medium":
	// do some medium-sized arse related stuff
	break;
	
	case "huge":
	// do some huge arse related stuff
	break;	
	
}

OK - got that.  now for the real thing!
||||||||||||||||||||||||||||||||||||||||||||||||||| */



//begin switch
switch()
{
// all possible 'cases' go below here

	//first case
	case "":
	// do first case stuff
	break;
	
	// second case
	case "":
	// do second case stuff
	break;	
	
	// etc... etc... add as many more 'cases' as needed

// all possible 'cases' go above here
}
// end switch

Initial URL

                                

Initial Description
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!

Initial Title
actionscript switch statement

Initial Tags
actionscript, flash

Initial Language
ActionScript