http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/SimpleTweenEffectExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/SimpleTweenEffectExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/SimpleTweenEffectExample.mxml new file mode 100755 index 0000000..93e236c --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/SimpleTweenEffectExample.mxml @@ -0,0 +1,73 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the TweenEffect class. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.events.TweenEvent; + + // Event handler for the tweenUpdate and tweenEnd effects. + private function tweenUpdateHandler(event:TweenEvent):void { + // Access current width of the image. + currentWidth.text="Current width (in pixels): " + String(event.value[0]); + } + + // Event handler for the reset button. + private function resetHandler():void { + expand.end(); + img.width=30; + currentWidth.text="Current width (in pixels): 30"; + img.height=60; + button1.enabled=true; + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:Resize id="expand" target="{img}" widthTo="100" heightTo="200" + duration="10000" + tweenUpdate="tweenUpdateHandler(event);" + tweenEnd="tweenUpdateHandler(event);"/> + </fx:Declarations> + + <mx:Panel title="Resize Effect Example" width="100%" height="100%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Text width="100%" color="blue" + text="Use the Button controls to resize the image."/> + + <mx:HBox width="100%"> + <mx:Image id="img" width="30" height="60" + source="@Embed(source='assets/ApacheFlexLogo.png')"/> + <mx:Text id="currentWidth" height="20" width="100%"/> + </mx:HBox> + + <mx:ControlBar> + <mx:Button id="button1" label="Start" click="expand.play(); button1.enabled=false;"/> + <mx:Button label="Pause" click="expand.pause();"/> + <mx:Button label="Resume" click="expand.resume();"/> + <mx:Button label="Reverse" click="expand.reverse();"/> + <mx:Button label="End" click="expand.end();"/> + <mx:Button label="Reset" click="resetHandler();"/> + </mx:ControlBar> + + </mx:Panel> +</mx:Application>
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/SoundEffectExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/SoundEffectExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/SoundEffectExample.mxml new file mode 100755 index 0000000..cdbf299 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/SoundEffectExample.mxml @@ -0,0 +1,36 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the SoundEffect effect. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Declarations> + <mx:SoundEffect id="mySounds" source="@Embed(source='./assets/ping.mp3')"/> + </fx:Declarations> + + <mx:Panel title="Sound Effect Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Label width="100%" color="blue" + text="Click on the logo to hear the sound effect."/> + + <mx:Image id="flex" source="@Embed(source='assets/ApacheFlexLogo.png')" + mouseDownEffect="{mySounds}"/> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/WipeDownExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/WipeDownExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeDownExample.mxml new file mode 100755 index 0000000..7363a7c --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeDownExample.mxml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the WipeDown effect. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Declarations> + <mx:WipeDown id="wipeOut" duration="1000"/> + <mx:WipeDown id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeDown Effect Example" width="95%" height="95%" + paddingTop="5" paddingLeft="10" paddingRight="10" paddingBottom="5"> + + <mx:Text width="100%" color="blue" + text="Use the WipeDown effect to show or hide the text and image."/> + + <mx:Label text="Apache Flex" + fontSize="14" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:Image source="@Embed(source='assets/ApacheFlexLogo.png')" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/WipeLeftExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/WipeLeftExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeLeftExample.mxml new file mode 100755 index 0000000..6c3b6de --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeLeftExample.mxml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the WipeLeft effect. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Declarations> + <mx:WipeLeft id="wipeOut" duration="1000"/> + <mx:WipeLeft id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeLeft Effect Example" width="95%" height="95%" + paddingTop="5" paddingLeft="10" paddingRight="10" paddingBottom="5"> + + <mx:Text width="100%" color="blue" + text="Use the WipeLeft effect to show or hide the text and image."/> + + <mx:Label text="Apache Flex" + fontSize="14" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:Image source="@Embed(source='assets/ApacheFlexLogo.png')" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/WipeRightExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/WipeRightExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeRightExample.mxml new file mode 100755 index 0000000..bd3d0fa --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeRightExample.mxml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the WipeRight effect. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Declarations> + <mx:WipeRight id="wipeOut" duration="1000"/> + <mx:WipeRight id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeRight Effect Example" width="95%" height="95%" + paddingTop="5" paddingLeft="10" paddingRight="10" paddingBottom="5"> + + <mx:Text width="100%" color="blue" + text="Use the WipeRight effect to show or hide the text and image."/> + + <mx:Label text="Apache Flex" + fontSize="14" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:Image source="@Embed(source='assets/ApacheFlexLogo.png')" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/WipeUpExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/WipeUpExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeUpExample.mxml new file mode 100755 index 0000000..dce394c --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/WipeUpExample.mxml @@ -0,0 +1,45 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the WipeUp effect. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Declarations> + <mx:WipeUp id="wipeOut" duration="1000"/> + <mx:WipeUp id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeUp Effect Example" width="95%" height="95%" + paddingTop="5" paddingLeft="10" paddingRight="10" paddingBottom="5"> + + <mx:Text width="100%" color="blue" + text="Use the WipeUp effect to show or hide the text and image."/> + + <mx:Label text="Apache Flex" + fontSize="14" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:Image source="@Embed(source='assets/ApacheFlexLogo.png')" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/ZoomEffectExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/ZoomEffectExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/effects/ZoomEffectExample.mxml new file mode 100755 index 0000000..0695d58 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/effects/ZoomEffectExample.mxml @@ -0,0 +1,56 @@ +<?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. + --> + +<!-- Simple example to demonstrate the Zoom effect. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + import flash.events.MouseEvent; + + public function doZoom(event:MouseEvent):void { + if (zoomAll.isPlaying) { + zoomAll.reverse(); + } + else { + // If this is a ROLL_OUT event, play the effect backwards. + // If this is a ROLL_OVER event, play the effect forwards. + zoomAll.play([event.target], event.type == MouseEvent.ROLL_OUT ? true : false); + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:Zoom id="zoomAll" zoomWidthTo="1" zoomHeightTo="1" zoomWidthFrom=".5" zoomHeightFrom=".5" /> + </fx:Declarations> + + <mx:Panel title="Zoom Effect Example" width="95%" height="95%" horizontalAlign="center" + paddingTop="5" paddingLeft="10" paddingRight="10" paddingBottom="5"> + + <mx:Text width="100%" color="blue" + text="Move the mouse over the image to enlarge it. Move the mouse off of the image to shrink it."/> + + <mx:Image id="img" + source="@Embed(source='assets/ApacheFlexLogo.png')" + scaleX=".5" scaleY=".5" + rollOver="doZoom(event)" + rollOut="doZoom(event)"/> + + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ApacheFlexLogo.png ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ApacheFlexLogo.png b/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ApacheFlexLogo.png new file mode 100644 index 0000000..4ff037f Binary files /dev/null and b/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ApacheFlexLogo.png differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/assets/OpenSans-Regular.ttf ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/assets/OpenSans-Regular.ttf b/TourDeFlex/TourDeFlex3/src/mx/effects/assets/OpenSans-Regular.ttf new file mode 100644 index 0000000..db43334 Binary files /dev/null and b/TourDeFlex/TourDeFlex3/src/mx/effects/assets/OpenSans-Regular.ttf differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ping.mp3 ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ping.mp3 b/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ping.mp3 new file mode 100644 index 0000000..2eb90ea Binary files /dev/null and b/TourDeFlex/TourDeFlex3/src/mx/effects/assets/ping.mp3 differ http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/CurrencyFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/CurrencyFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/CurrencyFormatterExample.mxml new file mode 100755 index 0000000..82ad2c0 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/CurrencyFormatterExample.mxml @@ -0,0 +1,73 @@ +<?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. + --> + +<!-- Simple example to demonstrate the CurrencyFormatter. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.events.ValidationResultEvent; + private var vResult:ValidationResultEvent; + + // Event handler to validate and format input. + private function Format():void { + + vResult = numVal.validate(); + + if (vResult.type==ValidationResultEvent.VALID) { + var temp:Number=Number(priceUS.text); + formattedUSPrice.text= usdFormatter.format(temp); + } + + else { + formattedUSPrice.text=""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:CurrencyFormatter id="usdFormatter" precision="2" + currencySymbol="$" decimalSeparatorFrom="." + decimalSeparatorTo="." useNegativeSign="true" + useThousandsSeparator="true" alignSymbol="left"/> + + <mx:NumberValidator id="numVal" source="{priceUS}" property="text" + allowNegative="true" domain="real"/> + </fx:Declarations> + + <mx:Panel title="CurrencyFormatter Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter U.S. dollar amount:"> + <mx:TextInput id="priceUS" text="" width="50%"/> + </mx:FormItem> + + <mx:FormItem label="Formatted amount: "> + <mx:TextInput id="formattedUSPrice" text="" width="50%" editable="false"/> + </mx:FormItem> + + <mx:FormItem> + <mx:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/DateFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/DateFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/DateFormatterExample.mxml new file mode 100755 index 0000000..9a2e875 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/DateFormatterExample.mxml @@ -0,0 +1,67 @@ +<?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. + --> + +<!-- Simple example to demonstrate the DateFormatter. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.events.ValidationResultEvent; + private var vResult:ValidationResultEvent; + + // Event handler to validate and format input. + private function Format():void + { + vResult = dateVal.validate(); + if (vResult.type==ValidationResultEvent.VALID) { + formattedDate.text=dateFormatter.format(dob.text); + } + + else { + formattedDate.text= ""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:DateFormatter id="dateFormatter" formatString="month: MM, day: DD, year: YYYY"/> + + <mx:DateValidator id="dateVal" source="{dob}" property="text" inputFormat="mm/dd/yyyy"/> + </fx:Declarations> + + <mx:Panel title="DateFormatter Example" width="95%" height="95%" + paddingTop="10" paddingLeft="5" paddingRight="5" paddingBottom="10"> + + <mx:Form width="100%"> + <mx:FormItem label="Enter date (mm/dd/yyyy):" width="100%"> + <mx:TextInput id="dob" text=""/> + </mx:FormItem> + + <mx:FormItem label="Formatted date: " width="100%"> + <mx:TextInput id="formattedDate" text="" editable="false"/> + </mx:FormItem> + + <mx:FormItem> + <mx:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/NumberFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/NumberFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/NumberFormatterExample.mxml new file mode 100755 index 0000000..0a990ba --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/NumberFormatterExample.mxml @@ -0,0 +1,70 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate NumberFormatter. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.events.ValidationResultEvent; + private var vResult:ValidationResultEvent; + + // Event handler to validate and format input. + private function Format():void + { + vResult = numVal.validate(); + if (vResult.type==ValidationResultEvent.VALID) { + + formattedNumber.text= numberFormatter.format(inputVal.text); + } + + else { + formattedNumber.text= ""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:NumberFormatter id="numberFormatter" precision="4" + useThousandsSeparator="true" useNegativeSign="true"/> + + <mx:NumberValidator id="numVal" source="{inputVal}" property="text" + allowNegative="true" domain="real"/> + </fx:Declarations> + + <mx:Panel title="NumberFormatter Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter number:"> + <mx:TextInput id="inputVal" text="" width="50%"/> + </mx:FormItem> + + <mx:FormItem label="Formatted number (precision=4): "> + <mx:TextInput id="formattedNumber" editable="false" width="50%"/> + </mx:FormItem> + + <mx:FormItem> + <mx:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/PhoneFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/PhoneFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/PhoneFormatterExample.mxml new file mode 100755 index 0000000..699e0d9 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/PhoneFormatterExample.mxml @@ -0,0 +1,69 @@ +<?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. + --> + +<!-- Simple example to demonstrate PhoneFormatter. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.events.ValidationResultEvent; + private var vResult:ValidationResultEvent; + + // Event handler to validate and format input. + private function Format():void + { + vResult = pnVal.validate(); + if (vResult.type==ValidationResultEvent.VALID) { + formattedPhone.text= phoneFormatter.format(phone.text); + } + + else { + formattedPhone.text= ""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:PhoneFormatter id="phoneFormatter" + formatString="(###) ###-####" validPatternChars="#-() "/> + + <mx:PhoneNumberValidator id="pnVal" source="{phone}" property="text" + allowedFormatChars=""/> + </fx:Declarations> + + <mx:Panel title="PhoneFormatter Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter a 10-digit phone number:"> + <mx:TextInput id="phone" text="" width="75%"/> + </mx:FormItem> + + <mx:FormItem label="Formatted phone number: "> + <mx:TextInput id="formattedPhone" text="" width="75%" editable="false"/> + </mx:FormItem> + + <mx:FormItem> + <mx:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/SimpleFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/SimpleFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/SimpleFormatterExample.mxml new file mode 100755 index 0000000..45787d5 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/SimpleFormatterExample.mxml @@ -0,0 +1,67 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the Formatter class. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + // Event handler to format the input. + private function Format():void + { + // The format() method returns the formatted String, + // or an empty String if there is an error. + var formattedVal:String = numberFormatter.format(inputVal.text); + + if (formattedVal.length==0) { + // If there is an error, the Format.error property + // contains the reason. + formattedNumber.text=numberFormatter.error; + } + + else { + formattedNumber.text=formattedVal; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:NumberFormatter id="numberFormatter"/> + </fx:Declarations> + + <mx:Panel title="NumberFormatter Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter number - a letter is invalid:"> + <mx:TextInput id="inputVal" text="" width="75%"/> + </mx:FormItem> + + <mx:FormItem label="Formatted number: "> + <mx:TextInput id="formattedNumber" editable="false" width="75%"/> + </mx:FormItem> + + <mx:FormItem> + <mx:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/SwitchSymbolFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/SwitchSymbolFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/SwitchSymbolFormatterExample.mxml new file mode 100755 index 0000000..4bc47a0 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/SwitchSymbolFormatterExample.mxml @@ -0,0 +1,63 @@ +<?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. + --> + +<!-- Simple example to demonstrate SwitchSymbolFormatter. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.formatters.SwitchSymbolFormatter; + import mx.events.ValidationResultEvent; + + private var vResult:ValidationResultEvent; + + // Event handler to validate and format input. + private function Format():void + { + vResult = scVal.validate(); + + if (vResult.type==ValidationResultEvent.VALID) { + var switcher:SwitchSymbolFormatter=new SwitchSymbolFormatter('#'); + + formattedSCNumber.text = + switcher.formatValue("Formatted Social Securty number: ###-##-#### ", scNum.text); + } + + else { + formattedSCNumber.text= ""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:SocialSecurityValidator id="scVal" source="{scNum}" property="text"/> + </fx:Declarations> + + <mx:Panel title="SwitchSymbolFormatter Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Label text="Enter a 9 digit Social Security number with no separator characters:"/> + <mx:TextInput id="scNum" text="" maxChars="9" width="50%"/> + + <mx:Button label="Validate and Format" click="Format();"/> + <mx:TextInput id="formattedSCNumber" editable="false" width="75%"/> + + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/formatters/ZipCodeFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/formatters/ZipCodeFormatterExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/formatters/ZipCodeFormatterExample.mxml new file mode 100755 index 0000000..92fa718 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/formatters/ZipCodeFormatterExample.mxml @@ -0,0 +1,68 @@ +<?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. + --> + +<!-- Simple example to demonstrate ZipCodeFormatter. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + + import mx.events.ValidationResultEvent; + private var vResult:ValidationResultEvent; + + // Event handler to validate and format input. + private function Format():void + { + vResult = zcVal.validate(); + + if (vResult.type==ValidationResultEvent.VALID) { + formattedZipcode.text= zipFormatter.format(zip.text); + } + + else { + formattedZipcode.text= ""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:ZipCodeFormatter id="zipFormatter" formatString="#####-####"/> + + <mx:ZipCodeValidator id="zcVal" source="{zip}" property="text" allowedFormatChars=""/> + </fx:Declarations> + + <mx:Panel title="ZipCodeFormatter Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form width="100%"> + <mx:FormItem label="Enter a 5 or 9 digit U.S. ZIP code:" width="100%"> + <mx:TextInput id="zip" text=""/> + </mx:FormItem> + + <mx:FormItem label="Formatted ZIP code: " width="100%"> + <mx:TextInput id="formattedZipcode" text="" editable="false"/> + </mx:FormItem> + + <mx:FormItem> + <mx:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/printing/AdvancedPrintDataGridExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/printing/AdvancedPrintDataGridExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/printing/AdvancedPrintDataGridExample.mxml new file mode 100755 index 0000000..38f0244 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/printing/AdvancedPrintDataGridExample.mxml @@ -0,0 +1,105 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- printing\ADGPrint.mxml --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + import mx.printing.*; + import mx.collections.ArrayCollection; + import mx.printing.PrintAdvancedDataGrid; + + // Create a PrintJob instance. + private function doPrint():void { + // Create an instance of the FlexPrintJob class. + var printJob:FlexPrintJob = new FlexPrintJob(); + + // Initialize the PrintAdvancedDataGrid control. + var printADG:PrintAdvancedDataGrid = + new PrintAdvancedDataGrid(); + // Exclude the PrintAdvancedDataGrid control from layout. + printADG.includeInLayout = false; + printADG.source = adg; + + // Add the print-specific control to the application. + addChild(printADG); + + // Start the print job. + if (printJob.start() == false) { + // User cancelled print job. + // Remove the print-specific control to free memory. + removeChild(printADG); + return; + } + + // Add the object to print. Do not scale it. + printJob.addObject(printADG, FlexPrintJobScaleType.NONE); + + // Send the job to the printer. + printJob.send(); + + // Remove the print-specific control to free memory. + removeChild(printADG); + } + + [Bindable] + private var dpHierarchy:ArrayCollection = new ArrayCollection([ + {Region:"Southwest", children: [ + {Region:"Arizona", children: [ + {Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, + {Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000}]}, + {Region:"Central California", children: [ + {Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000}]}, + {Region:"Nevada", children: [ + {Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000}]}, + {Region:"Northern California", children: [ + {Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, + {Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000}]}, + {Region:"Southern California", children: [ + {Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, + {Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}]} + ]} + ]); + + ]]> + </fx:Script> + + <mx:Panel title="PrintAdvancedDataGrid Control Example" + height="75%" width="75%" layout="horizontal" + paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"> + + <mx:AdvancedDataGrid id="adg" + width="100%" height="100%"> + <mx:dataProvider> + <mx:HierarchicalData source="{dpHierarchy}"/> + </mx:dataProvider> + <mx:columns> + <mx:AdvancedDataGridColumn dataField="Region"/> + <mx:AdvancedDataGridColumn dataField="Territory_Rep" + headerText="Territory Rep"/> + <mx:AdvancedDataGridColumn dataField="Actual"/> + <mx:AdvancedDataGridColumn dataField="Estimate"/> + </mx:columns> + </mx:AdvancedDataGrid> + + <mx:Button id="myButton" + label="Print" + click="doPrint();"/> + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintFooter.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintFooter.mxml b/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintFooter.mxml new file mode 100755 index 0000000..20e500b --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintFooter.mxml @@ -0,0 +1,32 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Custom control for the footer area of the printed page. --> + +<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + width="60%" horizontalAlign="right" > + <!-- Declare and initialize the product total variable. --> + + <fx:Script> + <![CDATA[ + [Bindable] + public var pTotal:Number = 0; + ]]> + </fx:Script> + <mx:Label text="Product Total: {pTotal}"/> +</mx:VBox> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintHeader.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintHeader.mxml b/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintHeader.mxml new file mode 100755 index 0000000..b2283fd --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintHeader.mxml @@ -0,0 +1,25 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Custom control for the header area of the printed page. --> + +<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + width="60%" horizontalAlign="right" > + + <mx:Label text="This is a placeholder for first page contents"/> +</mx:VBox> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintView.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintView.mxml b/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintView.mxml new file mode 100755 index 0000000..dabe443 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/printing/FormPrintView.mxml @@ -0,0 +1,77 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Custom control to print the DataGrid control on multiple pages. --> + +<mx:VBox xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns="*" backgroundColor="#FFFFFF" paddingTop="50" paddingBottom="50" paddingLeft="50"> + + <fx:Script> + <![CDATA[ + import mx.core.* + // Declare and initialize the variables used in the component. + // The application sets the actual prodTotal value. + [Bindable] + public var pageNumber:Number = 1; + [Bindable] + public var prodTotal:Number = 0; + + // Control the page contents by selectively hiding the header and + // footer based on the page type. + public function showPage(pageType:String):void { + if(pageType == "first" || pageType == "middle") { + // Hide the footer. + footer.includeInLayout=false; + footer.visible = false; + } + if(pageType == "middle" || pageType == "last") { + // The header won't be used again; hide it. + header.includeInLayout=false; + header.visible = false; + } + if(pageType == "last") { + // Show the footer. + footer.includeInLayout=true; + footer.visible = true; + } + //Update the DataGrid layout to reflect the results. + validateNow(); + } + ]]> + </fx:Script> + + <!-- The template for the printed page, with the contents for all pages. --> + <mx:VBox width="80%" horizontalAlign="left"> + <mx:Label text="Page {pageNumber}"/> + </mx:VBox> + + <FormPrintHeader id="header" /> + <!-- The data grid. The sizeToPage property is true by default, so the last + page has only as many grid rows as are needed for the data. --> + <mx:PrintDataGrid id="myDataGrid" width="60%" height="100%"> + <!-- Specify the columns to ensure that their order is correct. --> + <mx:columns> + <mx:DataGridColumn dataField="Index" /> + <mx:DataGridColumn dataField="Qty" /> + </mx:columns> + </mx:PrintDataGrid> + + <!-- Create a FormPrintFooter control and set its prodTotal variable. --> + <FormPrintFooter id="footer" pTotal="{prodTotal}" /> + +</mx:VBox> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/printing/PrintDataGridExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/printing/PrintDataGridExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/printing/PrintDataGridExample.mxml new file mode 100755 index 0000000..d3ef7e9 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/printing/PrintDataGridExample.mxml @@ -0,0 +1,143 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Main application to print a DataGrid control on multiple pages. --> + +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" initialize="initData();"> + + <fx:Script> + <![CDATA[ + + import mx.core.FlexGlobals; + import mx.printing.*; + import mx.collections.ArrayCollection; + import FormPrintView; + + // Declare variables and initialize simple variables. + [Bindable] + public var dgProvider:ArrayCollection; + public var footerHeight:Number = 20; + public var prodIndex:Number; + public var prodTotal:Number = 0; + + // Data initialization. + public function initData():void { + // Create the data provider for the DataGrid control. + dgProvider = new ArrayCollection; + } + + // Fill the dgProvider ArrayCollection with the specified items. + public function setdgProvider(items:int):void { + + prodIndex=1; + dgProvider.removeAll(); + for (var z:int=0; z<items; z++) + { + var prod1:Object = {}; + prod1.Qty = prodIndex * 7; + prod1.Index = prodIndex++; + prodTotal += prod1.Qty; + dgProvider.addItem(prod1); + } + } + + // The function to print the output. + public function doPrint():void { + + var printJob:FlexPrintJob = new FlexPrintJob(); + if (printJob.start()) { + // Create a FormPrintView control as a child of the current view. + var thePrintView:FormPrintView = new FormPrintView(); + FlexGlobals.topLevelApplication.addChild(thePrintView); + + //Set the print view properties. + thePrintView.width=printJob.pageWidth; + thePrintView.height=printJob.pageHeight; + thePrintView.prodTotal = prodTotal; + // Set the data provider of the FormPrintView component's data grid + // to be the data provider of the displayed data grid. + thePrintView.myDataGrid.dataProvider = myDataGrid.dataProvider; + // Create a single-page image. + thePrintView.showPage("single"); + // If the print image's data grid can hold all the provider's rows, + // add the page to the print job. + if(!thePrintView.myDataGrid.validNextPage) + { + printJob.addObject(thePrintView); + } + // Otherwise, the job requires multiple pages. + else + { + // Create the first page and add it to the print job. + thePrintView.showPage("first"); + printJob.addObject(thePrintView); + thePrintView.pageNumber++; + // Loop through the following code until all pages are queued. + while(true) + { + // Move the next page of data to the top of the print grid. + thePrintView.myDataGrid.nextPage(); + thePrintView.showPage("last"); + // If the page holds the remaining data, or if the last page + // was completely filled by the last grid data, queue it for printing. + // Test if there is data for another PrintDataGrid page. + if(!thePrintView.myDataGrid.validNextPage) + { + // This is the last page; queue it and exit the print loop. + printJob.addObject(thePrintView); + break; + } + else + // This is not the last page. Queue a middle page. + { + thePrintView.showPage("middle"); + printJob.addObject(thePrintView); + thePrintView.pageNumber++; + } + } + } + // All pages are queued; remove the FormPrintView control to free memory. + FlexGlobals.topLevelApplication.removeChild(thePrintView); + } + // Send the job to the printer. + printJob.send(); + } + ]]> + </fx:Script> + + <mx:Panel title="DataGrid Printing Example" height="75%" width="75%" + paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10"> + + <mx:DataGrid id="myDataGrid" dataProvider="{dgProvider}"> + <mx:columns> + <mx:DataGridColumn dataField="Index"/> + <mx:DataGridColumn dataField="Qty"/> + </mx:columns> + </mx:DataGrid> + + <mx:Text width="100%" color="blue" + text="Specify the number of lines and click Fill Grid first. Then you can click Print."/> + + <mx:TextInput id="dataItems" text="35"/> + + <mx:HBox> + <mx:Button id="setDP" label="Fill Grid" click="setdgProvider(int(dataItems.text));"/> + <mx:Button id="printDG" label="Print" click="doPrint();"/> + </mx:HBox> + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/states/StatesExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/states/StatesExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/states/StatesExample.mxml new file mode 100755 index 0000000..d0f70b1 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/states/StatesExample.mxml @@ -0,0 +1,56 @@ +<?xml version="1.0" ?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the States class. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <!-- Define one view state, in addition to the base state.--> + <mx:states> + <mx:State name="default" /> + <mx:State name="register" /> + </mx:states> + + <!-- Define a Panel container that defines the login form.--> + <mx:Panel title="Login" title.register="Register" id="loginPanel" + horizontalScrollPolicy="off" verticalScrollPolicy="off" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Text width="100%" color="blue" + text="Click the 'Need to Register?' link to change state. Click the 'Return to Login' link to return to the base state."/> + + <mx:Form id="loginForm"> + <mx:FormItem label="Username:"> + <mx:TextInput/> + </mx:FormItem> + <mx:FormItem label="Password:"> + <mx:TextInput/> + </mx:FormItem> + <mx:FormItem id="confirm" label="Confirm:" includeIn="register"> + <mx:TextInput/> + </mx:FormItem> + </mx:Form> + <mx:ControlBar> + <mx:LinkButton id="registerLink" label="Need to Register?" + click="currentState='register'" excludeFrom="register"/> + <mx:LinkButton id="loginLink" label="Return to Login" click="currentState='default'" + includeIn="register" /> + <mx:Spacer width="100%" id="spacer1"/> + <mx:Button label="Login" label.register="register" color.register="blue" id="loginButton" /> + </mx:ControlBar> + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/states/TransitionExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/states/TransitionExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/states/TransitionExample.mxml new file mode 100755 index 0000000..a246307 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/states/TransitionExample.mxml @@ -0,0 +1,82 @@ +<?xml version="1.0" ?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the Transition class. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <!-- Define one view state, in addition to the base state.--> + <mx:states> + <mx:State name="default" /> + <mx:State name="register" /> + </mx:states> + + <mx:transitions> + <!-- Define the transition from the base state to the Register state.--> + <mx:Transition id="toRegister" fromState="default" toState="register"> + <mx:Sequence targets="{[loginPanel, registerLink, confirm, loginLink, spacer1]}"> + <mx:RemoveChildAction/> + <mx:SetPropertyAction target="{loginPanel}" name="title"/> + <mx:SetPropertyAction target="{loginButton}" name="label"/> + <mx:SetStyleAction target="{loginButton}" name="color"/> + <mx:Resize target="{loginPanel}"/> + <mx:AddChildAction/> + </mx:Sequence> + </mx:Transition> + + <!-- Define the transition from the Register state to the base state.--> + <mx:Transition id="toDefault" fromState="register" toState="default"> + <mx:Sequence targets="{[loginPanel, registerLink, confirm, loginLink, spacer1]}"> + <mx:RemoveChildAction/> + <mx:SetPropertyAction target="{loginPanel}" name="title"/> + <mx:SetPropertyAction target="{loginButton}" name="label"/> + <mx:SetStyleAction target="{loginButton}" name="color"/> + <mx:Resize target="{loginPanel}"/> + <mx:AddChildAction/> + </mx:Sequence> + </mx:Transition> + </mx:transitions> + + <!-- Define a Panel container that defines the login form.--> + <mx:Panel title="Login" title.register="Register" id="loginPanel" + horizontalScrollPolicy="off" verticalScrollPolicy="off" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Text width="100%" color="blue" + text="Click the 'Need to Register?' link to change state. Click the 'Return to Login' link to return to the base state."/> + + <mx:Form id="loginForm"> + <mx:FormItem label="Username:"> + <mx:TextInput/> + </mx:FormItem> + <mx:FormItem label="Password:"> + <mx:TextInput/> + </mx:FormItem> + <mx:FormItem id="confirm" label="Confirm:" includeIn="register"> + <mx:TextInput/> + </mx:FormItem> + </mx:Form> + <mx:ControlBar> + <mx:LinkButton id="registerLink" label="Need to Register?" + click="currentState='register'" excludeFrom="register"/> + <mx:LinkButton id="loginLink" label="Return to Login" click="currentState='default'" + includeIn="register" /> + <mx:Spacer width="100%" id="spacer1"/> + <mx:Button label="Login" label.register="register" color.register="blue" id="loginButton" /> + </mx:ControlBar> + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/CreditCardValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/CreditCardValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/CreditCardValidatorExample.mxml new file mode 100755 index 0000000..cbf97a5 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/CreditCardValidatorExample.mxml @@ -0,0 +1,68 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the CreditCardValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + import mx.controls.Alert; + </fx:Script> + + <fx:Declarations> + <!-- Define model for the credit card data. --> + <fx:Model id="creditcard"> + <card> + <cardType>{cardTypeCombo.selectedItem.data}</cardType> + <cardNumber>{cardNumberInput.text}</cardNumber> + </card> + </fx:Model> + + <mx:CreditCardValidator id="ccV" + cardTypeSource="{creditcard}" cardTypeProperty="cardType" + cardNumberSource="{creditcard}" cardNumberProperty="cardNumber" + trigger="{myButton}" triggerEvent="click" + cardTypeListener="{cardTypeCombo}" + cardNumberListener="{cardNumberInput}" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + <mx:Panel title="CreditCardValidator Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form id="creditCardForm"> + <mx:FormItem label="Card Type"> + <mx:ComboBox id="cardTypeCombo"> + <mx:dataProvider> + <fx:Object label="American Express" data="American Express"/> + <fx:Object label="Diners Club" data="Diners Club"/> + <fx:Object label="Discover" data="Discover"/> + <fx:Object label="MasterCard" data="MasterCard"/> + <fx:Object label="Visa" data="Visa"/> + </mx:dataProvider> + </mx:ComboBox> + </mx:FormItem> + <mx:FormItem label="Credit Card Number"> + <mx:TextInput id="cardNumberInput"/> + </mx:FormItem> + <mx:FormItem> + <mx:Button id="myButton" label="Check Credit"/> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/CurrencyValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/CurrencyValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/CurrencyValidatorExample.mxml new file mode 100755 index 0000000..d937c34 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/CurrencyValidatorExample.mxml @@ -0,0 +1,45 @@ +<?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. + --> + +<!-- Simple example to demonstrate the CurrencyValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + import mx.controls.Alert; + </fx:Script> + + <fx:Declarations> + <mx:CurrencyValidator source="{priceUS}" property="text" precision="2" + trigger="{myButton}" triggerEvent="click" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + <mx:Panel title="CurrencyValidator Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter a U.S. dollar amount: "> + <mx:TextInput id="priceUS" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <mx:Button id="myButton" label="Validate"/> + </mx:FormItem> + </mx:Form> + </mx:Panel> +</mx:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/DateValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/DateValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/DateValidatorExample.mxml new file mode 100755 index 0000000..17293a9 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/DateValidatorExample.mxml @@ -0,0 +1,52 @@ +<?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. + --> + +<!-- Simple example to demonstrate the DateValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + import mx.controls.Alert; + </fx:Script> + + <fx:Declarations> + <fx:Model id="CheckModel"> + <dateInfo> + <DOB>{dob.text}</DOB> + </dateInfo> + </fx:Model> + + <mx:DateValidator source="{dob}" property="text" allowedFormatChars="/" + trigger="{myButton}" triggerEvent="click" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + <mx:Panel title="DateValidator Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter date of birth (mm/dd/yyyy): "> + <mx:TextInput id="dob" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <mx:Button id="myButton" label="Validate" /> + </mx:FormItem> + </mx:Form> + + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/EmailValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/EmailValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/EmailValidatorExample.mxml new file mode 100755 index 0000000..558971f --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/EmailValidatorExample.mxml @@ -0,0 +1,45 @@ +<?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. + --> + +<!-- Simple example to demonstrate the EmailValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + import mx.controls.Alert; + </fx:Script> + + <fx:Declarations> + <mx:EmailValidator source="{email}" property="text" + trigger="{myButton}" triggerEvent="click" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + <mx:Panel title="EmailValidator Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter an e-mail address: "> + <mx:TextInput id="email" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <mx:Button id="myButton" label="Validate" /> + </mx:FormItem> + </mx:Form> + </mx:Panel> + </mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/NumberValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/NumberValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/NumberValidatorExample.mxml new file mode 100755 index 0000000..979ce17 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/NumberValidatorExample.mxml @@ -0,0 +1,46 @@ +<?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. + --> + +<!-- Simple example to demonstrate the NumberValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + import mx.controls.Alert; + </fx:Script> + + <fx:Declarations> + <mx:NumberValidator source="{age}" property="text" integerError="Enter Integer value" + minValue="18" maxValue="50" domain="int" + trigger="{myButton}" triggerEvent="click" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + <mx:Panel title="NumberValidator Example" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter an age between 18 and 50: "> + <mx:TextInput id="age" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <mx:Button id="myButton" label="Validate" /> + </mx:FormItem> + </mx:Form> + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/PhoneNumberValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/PhoneNumberValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/PhoneNumberValidatorExample.mxml new file mode 100755 index 0000000..309802b --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/PhoneNumberValidatorExample.mxml @@ -0,0 +1,45 @@ +<?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. + --> + +<!-- Simple example to demonstrate the PhoneNumberValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + import mx.controls.Alert; + </fx:Script> + + <fx:Declarations> + <mx:PhoneNumberValidator source="{phone}" property="text" + trigger="{myButton}" triggerEvent="click" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + <mx:Panel title="Phone Number Validator Panel" width="75%" height="75%" + paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10"> + + <mx:Form> + <mx:FormItem label="Enter 10-digit phone number: "> + <mx:TextInput id="phone" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <mx:Button id="myButton" label="Validate" /> + </mx:FormItem> + </mx:Form> + </mx:Panel> +</mx:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/e1f9d1df/TourDeFlex/TourDeFlex3/src/mx/validators/RegExValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/mx/validators/RegExValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/mx/validators/RegExValidatorExample.mxml new file mode 100755 index 0000000..8ee9cf9 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/mx/validators/RegExValidatorExample.mxml @@ -0,0 +1,85 @@ +<?xml version="1.0"?> +<!-- + 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. + --> + +<!-- Simple example to demonstrate the RegExpValidator. --> +<mx:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx"> + + <fx:Script> + <![CDATA[ + import mx.events.ValidationResultEvent; + import mx.validators.*; + + // Write the results to the + private function handleResult(eventObj:ValidationResultEvent):void { + if (eventObj.type == ValidationResultEvent.VALID) + { + // For valid events, the results Array contains + // RegExpValidationResult objects. + var xResult:RegExpValidationResult; + reResults.text=""; + for (var i:uint = 0; i < eventObj.results.length; i++) + { + xResult = eventObj.results[i]; + reResults.text=reResults.text + xResult.matchedIndex + " " + + xResult.matchedString + "\n"; + } + } + else + { + reResults.text=""; + } + } + ]]> + </fx:Script> + + <fx:Declarations> + <mx:RegExpValidator id="regExpV" + source="{regex_text}" property="text" + flags="g" expression="{regex.text}" + valid="handleResult(event)" invalid="handleResult(event)" + trigger="{myButton}" triggerEvent="click"/> + </fx:Declarations> + + <mx:Panel title="RegExpValidator Example" width="95%" height="95%" + paddingTop="5" paddingLeft="5" paddingRight="5" paddingBottom="5"> + + <mx:Text width="100%" text="Instructions:"/> + <mx:Text width="100%" text="1. Enter text to search. By default, enter a string containing the letters ABC in sequence followed by any digit."/> + <mx:Text width="100%" text="2. Enter the regular expression. By default, enter ABC\d."/> + <mx:Text width="100%" text="3. Click the Button control to trigger the validation."/> + <mx:Text width="100%" text="4. The results show the index in the text where the matching pattern begins, and the matching pattern. "/> + + <mx:Form> + <mx:FormItem label="Enter text: "> + <mx:TextInput id="regex_text" text="xxxxABC4xxx" width="100%"/> + </mx:FormItem> + + <mx:FormItem label="Enter regular expression: "> + <mx:TextInput id="regex" text="ABC\d" width="100%"/> + </mx:FormItem> + + <mx:FormItem label="Results: "> + <mx:TextInput id="reResults" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <mx:Button id="myButton" label="Validate"/> + </mx:FormItem> + </mx:Form> + </mx:Panel> +</mx:Application> \ No newline at end of file