ArrayCollection as dataProvider for TabBar
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
import mx.events.ItemClickEvent;
import mx.controls.TabBar;
import mx.collections.ArrayCollection;
[Bindable]
private var STATE_ARRAY:ArrayCollection = new ArrayCollection([
{label:"A", data:"AA"},
{label:"B", data:"BB"},
{label:"C", data:"CC"}
]);
private function clickEvt(event:ItemClickEvent):void {
var targetComp:TabBar = TabBar(event.currentTarget);
forClick.text="label is: " + event.label + " index is: " + event.index + " capital is: " +
targetComp.dataProvider[event.index].data;
}
</mx:Script>
<mx:TabBar id="myTB" itemClick="clickEvt(event);">
<mx:dataProvider>{STATE_ARRAY}</mx:dataProvider>
</mx:TabBar>
<mx:TextArea id="forClick" width="150" />
</mx:Application>
Related examples in the same category