Using One Series of Conditional Statements for Several Different Objects?
-Let's say you have several doors on stage for a game.
-Each door has the ability to change color.
-When any two doors are the same color, a player can move between
those two doors.
To do this, I use code similar to the following:
doorThree.addEventListener(MouseEvent.CLICK,dooraction);
function dooraction(event:MouseEvent){
if ("Blue") {
doorOne.gotoAndStop("Red");
doorTwo.gotoAndStop("Blue");
doorThree.gotoAndStop("Yellow");
}
else if ("Red"){
doorOne.gotoAndStop("Blue");
doorTwo.gotoAndStop("Yellow");
doorThree.gotoAndStop("Red");
}
}
Is there a way to use this one series of If statements for all doors, or must I copy and paste
the same instructions for each door instance? In the game I'm planning, each door actually has more than two dozen states, so if I can use just one series of if statements, I'd like to do that.