开发者

Flex Problem Enabling and Disabling Button in List

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.numChildre开发者_Python百科n; 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?


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜