1
votes

Flash CS4, AS2

I am making a Flash tour. I have 3 sections: About, Rentals, Neighborhood. All the sections are within MCs on the same Frame. I am using conditonal statements on the Nav buttons to turn the visibility on/off in order to navigate the tour. However, now when the same button is pressed, the MC toggles on/off.

I want to disable the button when it is pressed and then enable the button when the other two buttons are pressed.

How do I write this code?

Thanks!

2

2 Answers

0
votes

Might I suggest a variant to Branden's answer ? Why not store the last selectedButton in a variable and keep updating that one, instead of looping through all of the buttons again and again. Of course for a few buttons it wouldn't make much of a difference, but it's just a thought.

var buttonList:Array = [aboutButton, rentalButton, neighborhoodButton];
var selectedButton;

function selectButton():Void {
    selectedButton.enabled = true; 
    this.enabled = false;
    selectedButton = this;
}

for (i=0; i<buttonList.length; ++i) {
    buttonList[i].onRelease = selectButton;
}
0
votes

Here's the basic idea:

var buttonList:Array = [aboutButton, rentalButton, neighborhoodButton];

function selectButton():Void {
    for (i=0; i<buttonList.length; ++i) {
        buttonList[i].enabled = true;
    }

    this.enabled = false;
}

for (i=0; i<buttonList.length; ++i) {
    buttonList[i].onRelease = selectButton;
}

aboutButton.onRelease();