tags:

views:

645

answers:

2

How can I disable a single button in a buttonbar in Flex?

A: 

Check this post Disabling individual buttons on a Flex ButtonBar control

I copied you exact question and searched in google.

Shoban
+1  A: 

Hi, here is the sample app.

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
 creationComplete="onComplete();">
 <mx:Script>
  <![CDATA[
   import mx.controls.Button;
   private function onComplete():void {
    for ( var i:int=0; i<btns.numChildren; i++ ) {
     if ( i == 0 || i % 2 == 0 ) {
      Button(btns.getChildAt(i)).enabled = false;
     }
    }
   }
  ]]>
 </mx:Script>
 <mx:LinkBar id="btns">
  <mx:dataProvider>
   <mx:ArrayCollection>
    <mx:Array>
     <mx:Object label="Button 1" />
     <mx:Object label="Button 2" />
     <mx:Object label="Button 3" />
     <mx:Object label="Button 4" />
     <mx:Object label="Button 5" />
     <mx:Object label="Button 6" />
    </mx:Array>
   </mx:ArrayCollection>
  </mx:dataProvider>
 </mx:LinkBar>
</mx:WindowedApplication>

Basically you access individual buttons using

libkBarInst.getChildAt(n)

which gives you a Button. Hope that helps.

radekg