Format List with labelFunction property
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >
<mx:Script>
private function formatData(item:Object):String
{
return dateF.format(item.data);
}
private function changeData(obj:Object):void
{
dateTxt.text = dateF.format(obj.data);
}
</mx:Script>
<mx:ArrayCollection id="myAC">
<mx:Object label="{new Date(2010,1,1)}" data="{new Date(2010,1,1)}"/>
<mx:Object label="{new Date(2010,1,2)}" data="{new Date(2010,1,2)}"/>
<mx:Object label="{new Date(2010,1,3)}" data="{new Date(2010,1,3)}"/>
</mx:ArrayCollection>
<mx:DateFormatter id="dateF" formatString="EEE, DD/MMM/YYYY" />
<mx:TextInput id="dateTxt" editable="false" />
<mx:ComboBox id="myCombo" dataProvider="{myAC}"
labelFunction="formatData"
change="changeData(myCombo.selectedItem)" />
</mx:Application>
Related examples in the same category