Hi,
In an extension, if I try something like:
if (x==1 or y==1){
//do something
}
The script won't load. If I get rid of the "or" and do a nested "if" statement, it works fine. Is this a known limitation?
Extensions have boolean logic limitations?
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
-
duncanhall
- Posts: 29
- Joined: 04 May 2008, 14:52
- Contact:
I would advise the exact opposite of what ptd suggests.
The compiler is more than happy to recognise (x==1 || x==2) as two seperate conditionals, and the added parenthesis just make it harder to spot exactly what is being evaluated. I would only really include the nested parenthesis when you have multiple evaluations in each conditional.
eg:
if (( x > 3 && x < 10 ) || (x > 20 && x < 30))
The compiler is more than happy to recognise (x==1 || x==2) as two seperate conditionals, and the added parenthesis just make it harder to spot exactly what is being evaluated. I would only really include the nested parenthesis when you have multiple evaluations in each conditional.
eg:
if (( x > 3 && x < 10 ) || (x > 20 && x < 30))
- Carl Lydon
- Posts: 298
- Joined: 12 Nov 2007, 16:15
- Location: NYC
Thanks
Thanks for all the advice. The main thing was that my Flash compiler always recognized "and"..."or", but that Smartfox extensions might not. I'll be in the habit now of always using || or &&