Mega Code Archive

 
Categories / Flex / Data Model
 

Using a NumberFormatter to format a number to two decimal places

<?xml version="1.0"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"     backgroundColor="white">     <mx:XML id="myData">         <root>             <item name="weight" value="2.5" />         </root>     </mx:XML>     <mx:NumberFormatter id="fmtNumber" precision="2" />     <mx:Label         text="Weight {fmtNumber.format(myData.item.@value)}lbs" /> </mx:Application>