[F8] Help with making AS smaller, please?
I am making a menu and on it are MCs that act as buttons. They have 2 states (on and off) and I have the AS set up where if you turn one "on" all the others go "off"
The problem is that I have 16 of these buttons and the AS to turn each off is getting very long. I am not sure if there is a way to make it better or not. I was thinking maybe one of thse arrays or the "if i>=0 {do this" type of thing.
Usually I jst code on button to do what ever, but I am trying new things (external AS files and functions and such) and I am not sure how to set it up.
Currently the AS for one button looks like this:
Code:
if (tog1._currentframe == 1) {
tog1.gotoAndStop(2);
togIsOn = 1;
tog2.gotoAndStop(1);
tog3.gotoAndStop(1);
tog4.gotoAndStop(1);
tog5.gotoAndStop(1);
tog6.gotoAndStop(1);
tog7.gotoAndStop(1);
tog8.gotoAndStop(1);
tog9.gotoAndStop(1);
tog10.gotoAndStop(1);
tog11.gotoAndStop(1);
tog12.gotoAndStop(1);
tog13.gotoAndStop(1);
tog14.gotoAndStop(1);
tog15.gotoAndStop(1);
tog16.gotoAndStop(1);
} else if (tog1._currentframe == 2) {
tog1.gotoAndPlay(3);
togIsOn = 0;
}
};
Each button is an instance of MC named "tog" and they all have numbers (1 - 16) added to the "tog" for an instance name (tog1, tog12, etc.)
I am sure there is something I can do to to shorten this code so I don't have to put this code inside each button function. I just don't know how. Also, the "togIsOn = #" is just a check for another button. If the tog is set to "on" togIsOn will == that tog's number, if the tog is then turned off (all off) then togIsOn == 0;.
Anyone have an idea?
~MoN