tags:

views:

265

answers:

1

Hi all,

I have a HGroup with some buttons inside which is my application's menu.

<s:HGroup id="nav">
    <s:Button id="homeButton" label="Home" />
    <s:Button id="showroomButton" label="Showroom" />
    <s:Button label="Catalogue" />
    <s:Button label="Offers" />
    <s:Button label="My Account" />
    <s:Button label="My Orders" />
</s:HGroup>

What I want is when I click for example the #homeButton to change it's state to "over", become disabled and reset all other buttons to the "up" state.

I've written this function

    private function resetNavState():void {
        for(var i:int = 0,ii:int = nav.numChildren-1;i<ii;i++) {
        Button(nav.getChildAt(i)).mouseEnabled = true;
        Button(nav.getChildAt(i)).skin.setCurrentState("up",true);
    }
}

And then on the homeButton click handler for example i use

protected function homeButton_clickHandler(event:MouseEvent):void
{
    resetNavState();
    currentState = "home";
    homeButton.skin.setCurrentState("over",true);
    homeButton.mouseEnabled = false;

}

I resets the states of the #nav buttons but it doesn't change the state of the pressed button.

Any ideas?

Thanx in advance

A: 

You'll want to place your buttons in a in a <s:ButtonBar /> control rather than the HGroup.

quoo
Do you mean a navigator?
chchrist
sorry about that, forgot code tags:)
quoo
I'd use a ButtonBar but I don't want to use viewstacks but states. Also I find it more difficult to skin a ButtonBar...
chchrist
You're not limited to using ViewStacks with ButtonBars, you can execute whatever logic you want by handling the ButtonBar's change event. Why do you find them difficult to style?
quoo
After reading more carefully the docs I've finally understood how it works :) Thnx
chchrist