At 10/23/09 03:27 PM, K-Guare wrote:
Well, a disgusting, inefficient option would be
to use a logical OR operator, the ||.
FYI that's actually not an inefficient option, any fluff you do on top of that is going to make it slower.
Just imperceptibly slower, so it's not an issue.
(in c++ at least, don't know for sure about flash), || and && "short circuit" when they've reached a point where they can deduce the value of the whole statement
I.E. (excuse the c++ it's been a few months since i've touched flash)
int a = 4;
if(a == 1 || a == 2 || a == 3 || a == 4 || a == 5 || a == 6 || a == 7){
STUFF
}
It'll evaluate a==1, a==2, a==3, and stop when a==4 returns 1 (because anything || with 1 still returns 1, there's no need to evaluate the other statements).
Similarly with &&, when one statement in a chain is evaluated to 0, it'll stop and continue.
The simple way to test this in flash would be to stick a function call at the end of a chain that should be short circuited early, if the function gets called then FLASH IS STUPID
this tidbit of information is brought to you by the letter F