I am using actionscript 3 to make a point and click game. On frame 1 there are two buttons, button 1 and 2. On frame 3 there are two buttons, button A and B.
I want it so that after I click button 1 on frame 1, button A on frame 3 will be hidden or when I click button 2 on frame 1, button B on frame 3 will be hidden. The buttons that are hidden do not do anything when you click them.
thanks in advance
If you try to remove something that is not in the display list yet Flash will thrown an error. I guess the best solution here is setting up a timeline variable to keep track of which button you have pressed. Something like this:
on frame 1
var b1:Boolean = false;
var b2:Boolean = false;
button1.addEventListener(MouseEvent.MOUSE_DOWN, checkButton);
button2.addEventListener(MouseEvent.MOUSE_DOWN, checkButton);
function checkButton(e:MouseEvent):void
{
if(e.target.name == button1) b1 = true;
else b2 = true;
gotoAndPlay(3);
}
on frame 3
myButtomA.visible = false;
myButtomB.visible = false;
if (b1) myButtomA.visible = true;
if (b2) myButtomB.visible = true;