Disable individual buttons in the button bar

How to disable a single button on a button bar in Flex?

+3
source share
2 answers

Here is an example application.

<?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 get access to individual buttons with

libkBarInst.getChildAt(n)

which gives you a button. Hope this helps.

+3
source

Source: https://habr.com/ru/post/1710646/


All Articles