views:

1331

answers:

3

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!

A: 

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();
Branden Hall
Beautiful! Works perfectly. Thanks so much!
jecca411
A: 

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;
}
George Profenza
I tried this one but it didn't seem to work. I may not have been using the code right... Thanks though!
jecca411
that is strage, I've tested it using buttons named as listed in buttonList. anyway, glad you got it sorted out.
George Profenza
I got this working! Not sure what the issue was before.
jecca411
A: 

Doesn't work at all, the first button doesn't link till the second button is pressed and then it stays on and doesn't revert to normal state.

???

Karl Dix