I was looking for some good Flash programming articles to add to by post Flash Programming – Good Articles, and came across Jim Bumgardner’s blog, which in turn led me to this solution he posted to the FlashKit forum 2-State Button.
In the examples he uses the XOR operator: ^
and the conditional operator: ?:
I’ve never been a fan of the conditional operator as the code to me, although succinct does not seem as clear as using if and else. To add to the confusion the operation is also known as Ternary operator. See the wikepedia definition Ternary_operation.
I’ll add the code from Flash help as a reference:
var timecode:String = (new Date().getHours() < 11) ? “AM” : “PM”;
The XOR operator seems like fun, although I’ve never found an instance where I could use it!