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