Alternative to multiple variables
If I have funcitons that are based on boolean conditions, normally I would set up a bunch of boolean variables for each condition and then have funciton check to see which ones are true, but what if I have a a bunch of variables? Then I would have to manually switch which ones are true or false a whole lot, and I feel like there is a better way using arrays or something. Any suggestions on I would do this?
Example:
var condition1:Boolean;
var condition2:Boolean;
var condition3:Boolean;
oneBtn.addeventListener(MouseEvent.CLICK, dostuff);
function doStuff(event:MouseEvent) {
gotoAndStop("newFrame");
condition1=true;
condition2=false;
condiition3=false;
}
twoBtn.addeventListener(MouseEvent.CLICK, dostuff2);
function doStuff2(event:MouseEvent) {
gotoAndStop("newFrame2");
condition1=false;
condition2=true;
condiition3=false;
}
etc…
Then on the frame "newFrame"
If (condition1) {
//do function
}
If (condition2) {
//do function
}
If (condition3) {
//do function
}
Is there a way I could do this with an array or something. If I had 12 variables could I say myArray[0,1,2,3,4,5,6,7,8,9,10,11] and tie the variables to each number and then on the buttons just tell it to set a number 5 to true and make everything else false.
I am just trying to simply my code, I know a little about Arrays dont really use them, and if they could help I want to learn how to make them work in my favor.
