When a case fails, it does not have a break statement, but there is a comment at the location of the break statement, which you see in the following case a note. When you write a switch statement, use the following format:
The code is as follows |
Copy Code |
Switch (condition) { Case A: Statement Failed Case B: Statement Break Case Z: Statement Break Default: Statement Break } |
Usage of default in switch statements:
Cases:
The code is as follows |
Copy Code |
function Not_set_yet () { Switch (_root.txt.text) { Case "Class One": numb = Random (26) +97; Case "Class two": numb = Random (26) +65; Default: var tt = random (2); if (TT = 1) { numb = Random (26) +97; } else { numb = Random (26) +65; } } } |
The meaning of this code is that when a class and class two are not established, then, the value of numb to take random (26) +97 and Random (26) +65;
Application examples
The code is as follows |
Copy Code |
var my_arr:array=new Array (); var _string:string=my_arr[math.floor (Math.random () *my_arr.length)]; Case "Pear": Break Trace ("Go for a walk!") Very handsome! "); Case "Belle One": Break Trace ("Go slow, don't fall!"); Case "Computer One": Break |