tags:

views:

22

answers:

2

I have a list with a dataprovider, it lists out buttons encapsulated in an item renderer. All I want it to do is have a skin that it changes to when it is clicked. I can get this to happen, but then it just goes back to its up state. I want it to stick on the down state, which I have to do by disabling the button.

So I tried this:

buttonList.selectedItem.enabled = false; 

for(var i:Number = 0; i< buttonList.numChildren; i++)
{
   var loopBtn = buttonList.getChildAt(i);

if(loopBtn != buttonList.selectedItem)
{
  loopBtn.enabled = true;
}

}

But this doesn't seem to work. What am I doing wrong here?

A: 

Maybe you want to use a toggle button here?

<mx:Button toggle="true" ... />

At least it would stay in the down state after being pressed.

ilikeorangutans
Thanks you, that fixed the problem with it not staying in the down state. But now all of them stay in that state unless I click them again. I feel like this shouldn't be that hard.
pfunc
A: 

You need a static variable 'selectedButton' in the class those buttons that retains the latest selected button.

on click you set the selectedButton back to non-selected before selecting the new one.

HTH

keyle