| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <!-- Sample program for spark.formatters.NumberValidator --> |
| <s:Application |
| xmlns:fx="http://ns.adobe.com/mxml/2009" |
| xmlns:s="library://ns.adobe.com/flex/spark" |
| xmlns:mx="library://ns.adobe.com/flex/mx"> |
| |
| <fx:Declarations> |
| <s:NumberValidator id="numberValidator" source='{inputNumber}' |
| property="text" trigger='{validateBtn}' |
| triggerEvent="click" /> |
| <s:NumberFormatter id="numberFormatter" useGrouping="true"/> |
| </fx:Declarations> |
| |
| <fx:Script> |
| <![CDATA[ |
| [Bindable] |
| private var number:Number = 123456789.12; |
| ]]> |
| </fx:Script> |
| |
| <mx:Form> |
| <mx:FormItem label="Input Locale ID Name"> |
| <mx:HBox> |
| <s:TextInput id="inputLocaleIDName" text="en-US"/> |
| <!-- Upon button click, sets the locale style on the document |
| UI component. The formatter will inherit this style. --> |
| <s:Button click="setStyle('locale', inputLocaleIDName.text);" |
| label="Apply"/> |
| </mx:HBox> |
| <mx:Text text="Example: 'en-US', 'fr-FR', 'ja-JP', 'ar-SA'"/> |
| </mx:FormItem> |
| |
| <mx:FormItem label="Allow Negative"> |
| <mx:CheckBox id="alowNegative" selected="true" |
| change="numberValidator.allowNegative = alowNegative.selected"/> |
| </mx:FormItem> |
| |
| <mx:FormItem label="Fractional Digits"> |
| <mx:TextInput id="fractionalDigits" text='{numberValidator.fractionalDigits}' |
| change="numberFormatter.fractionalDigits = |
| numberValidator.fractionalDigits = Number(fractionalDigits.text)"/> |
| </mx:FormItem> |
| |
| <mx:FormItem label="Actual Locale ID Name"> |
| <mx:Text text="{numberValidator.actualLocaleIDName}"/> |
| </mx:FormItem> |
| |
| <mx:FormItem label="Input number" > |
| <mx:HBox> |
| <mx:TextInput id="inputNumber" /> |
| <mx:Button id="validateBtn" label="Validate" /> |
| </mx:HBox> |
| </mx:FormItem> |
| |
| <mx:FormItem label="Example number"> |
| <mx:Text text="{numberFormatter.format(123456789.12)}"/> |
| </mx:FormItem> |
| </mx:Form> |
| </s:Application> |