ButtonBar click changed event : ButtonBar « Components « Flex






ButtonBar click changed event

ButtonBar click changed event
       

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:s="library://ns.adobe.com/flex/spark">
    <mx:Script>
        
            import mx.collections.ArrayCollection;
            import spark.events.IndexChangeEvent;
            import mx.controls.Alert;
            
            [Bindable]
            protected var btnBarData:ArrayCollection = new ArrayCollection(
                [
                    {label: 'Show Labels', mode: 'labels'},
                    {label: 'Show Titles', mode: 'titles'}
                ]
            );
            protected function btnBar_changeHandler(event:IndexChangeEvent):void{
                var selectedItem:Object = btnBarData.getItemAt(event.newIndex) as Object;
                switch(selectedItem.mode){
                    case "labels":
                        Alert.show('A');
                        break;
                    case "titles":
                        Alert.show('B');
                        break;
                    default:
                        break;
                }
            }
      
    </mx:Script>
    
    <s:ButtonBar id="btnBar"
                 dataProvider="{btnBarData}"
                 change="btnBar_changeHandler(event)"/>
    
</mx:Application>

   
    
    
    
    
    
    
  








Related examples in the same category

1.Use ButtonBar with Use ButtonBar with <mx:ButtonBar>
2.ButtonBar and an event listener for the itemClick eventButtonBar and an event listener for the itemClick event
3.A ButtonBar control automatically adds or removes children based on changes to the dataProvider propertyA ButtonBar control automatically adds or removes children based on changes to the dataProvider property
4.Spark ButtonBarSpark ButtonBar
5.ButtonBar defines an event listener for the change eventButtonBar defines an event listener for the change event
6.Adding style to ButtonBarAdding style to ButtonBar
7.Create a Spark ButtonBar control to navigate the ViewStack containerCreate a Spark ButtonBar control to navigate the ViewStack container
8.Creating an MX ButtonBar controlCreating an MX ButtonBar control