Conditional Switch Statements in AS3
This is something I wasn’t aware that you could do in a switch/case statement until recently. A lot of times developers will handle this with nested if/else statements.
For Example:
var myNum:Number = 7; switch (true) { case (myNum < 5): trace ("< 5") break; case (myNum > 5): trace ("> 5") break; }
Using switch (true)/switch (false) is pretty cool. You can use it for any sort of true/false comparisons, including comparing strings. The first one to evaluate true will trip the statement.