-
Hi,
Is there any way to use multiple variables in a if statement. For instance instead of individually typing :
if(colour1 == "yellow"){
'do whatever'
}
if(colour2 == "yellow"){
'do whatever'
}
Say you had 100 colours and all you want to find out is if any of them equal yellow or red is there anyway to do so something like below:
if(colour1 or colour2 or colour3 == "yellow" or "red"){
'do whatever'
}
I'm relatively new at code, just trying to make it tidier and more efficient.
Any help would be Appreciated.
-
Welcome to flavour country
I would use a loop for something like this.
Example:
Code:
for(i=1;i<=100;i++){
if(this["color"+i] == "yellow" || this["color"+i] == "red"){
trace("do stuff");
break;
}
}
Hope that helps.
-
Thanks for the reply Wiz,
Sounds like that might be the go, a loop will cut the amount of code down.
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|