mirror of
https://github.com/gryf/tagbar.git
synced 2025-12-17 19:40:27 +01:00
66 lines
2.4 KiB
XML
66 lines
2.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- http://blog.flexexamples.com/2007/12/13/rounding-numbers-in-flex-using-the-numberformatter-class/ -->
|
|
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
|
|
layout="vertical"
|
|
verticalAlign="middle"
|
|
backgroundColor="white">
|
|
|
|
<mx:Script>
|
|
<![CDATA[
|
|
import mx.collections.ArrayCollection;
|
|
import mx.formatters.NumberBaseRoundType;
|
|
|
|
private function button_click(evt:MouseEvent):void {
|
|
textInput.errorString = "";
|
|
numberFormatter.format(textInput.text);
|
|
if (numberFormatter.error) {
|
|
textInput.errorString = numberFormatter.error;
|
|
}
|
|
|
|
arrColl = new ArrayCollection();
|
|
|
|
numberFormatter.rounding = NumberBaseRoundType.NEAREST;
|
|
arrColl.addItem({type:numberFormatter.rounding,
|
|
value:numberFormatter.format(textInput.text)});
|
|
|
|
numberFormatter.rounding = NumberBaseRoundType.UP;
|
|
arrColl.addItem({type:numberFormatter.rounding,
|
|
value:numberFormatter.format(textInput.text)});
|
|
|
|
numberFormatter.rounding = NumberBaseRoundType.DOWN;
|
|
arrColl.addItem({type:numberFormatter.rounding,
|
|
value:numberFormatter.format(textInput.text)});
|
|
|
|
numberFormatter.rounding = NumberBaseRoundType.NONE;
|
|
arrColl.addItem({type:numberFormatter.rounding,
|
|
value:numberFormatter.format(textInput.text)});
|
|
}
|
|
]]>
|
|
</mx:Script>
|
|
|
|
<mx:ArrayCollection id="arrColl" />
|
|
|
|
<mx:NumberFormatter id="numberFormatter"
|
|
precision="2"
|
|
rounding="up" />
|
|
|
|
<mx:ApplicationControlBar dock="true">
|
|
<mx:Form styleName="plain">
|
|
<mx:FormItem label="number:"
|
|
direction="horizontal">
|
|
<mx:TextInput id="textInput"
|
|
text="2.0499"
|
|
restrict="[0-9.-]"
|
|
maxChars="6" />
|
|
<mx:Button label="format"
|
|
click="button_click(event);" />
|
|
</mx:FormItem>
|
|
</mx:Form>
|
|
</mx:ApplicationControlBar>
|
|
|
|
<mx:DataGrid id="dataGrid"
|
|
dataProvider="{arrColl}"
|
|
rowCount="4" />
|
|
|
|
</mx:Application>
|