http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/ResizeEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/ResizeEffectExample.mxml b/tourdeflexmodules/src/mx/effects/ResizeEffectExample.mxml new file mode 100755 index 0000000..e936e6d --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/ResizeEffectExample.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 Resize effect. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Declarations> + <mx:Resize id="expand" target="{img}" widthTo="100" heightTo="200"/> + <mx:Resize id="contract" target="{img}" widthTo="30" heightTo="60"/> + </fx:Declarations> + + <mx:Panel title="Resize Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + text="Use the Button controls to resize the image."/> + + <mx:Image id="img" width="30" height="60" + source="@Embed(source='assets/ApacheFlexLogo.png')"/> + + <mx:ControlBar> + <mx:Button label="Expand" click="expand.end(); expand.play()"/> + <mx:Button label="Contract" click="contract.end(); contract.play()"/> + </mx:ControlBar> + + </mx:Panel> +</mx:Module>
http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/RotateEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/RotateEffectExample.mxml b/tourdeflexmodules/src/mx/effects/RotateEffectExample.mxml new file mode 100755 index 0000000..08f2f89 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/RotateEffectExample.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 the Rotate effect. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Script> + <![CDATA[ + [Bindable] + public var angle:int=0; + + private function rotateImage():void { + rotate.end(); + angle += 45; + rotate.play(); + } + ]]> + </fx:Script> + + <fx:Style> + @font-face { + src:url("./assets/OpenSans-Regular.ttf"); + fontFamily: OpenSans; + embedAsCFF: false; + } + </fx:Style> + + <fx:Declarations> + <mx:Rotate id="rotate" angleFrom="{angle-45}" angleTo="{angle}" target="{myVB}"/> + </fx:Declarations> + + <mx:Panel title="Rotate Effect Example" layout="horizontal" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:VBox id="myVB" width="50%" horizontalAlign="center"> + <mx:Label text="Apache Flex" + fontFamily="OpenSans" fontSize="14"/> + + <mx:Image id="img" + width="50%" height="50%" + source="@Embed(source='assets/ApacheFlexLogo.png')"/> + </mx:VBox> + + <mx:Text width="50%" + text="Click the button to rotate the image 45 degrees. Use an embedded font when applying the Rotate effect to text."/> + + <mx:ControlBar> + <mx:Button label="Rotate 45 Degrees" click="rotateImage()"/> + </mx:ControlBar> + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/SequenceEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/SequenceEffectExample.mxml b/tourdeflexmodules/src/mx/effects/SequenceEffectExample.mxml new file mode 100755 index 0000000..7db2617 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/SequenceEffectExample.mxml @@ -0,0 +1,50 @@ +<?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 Sequence effect. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Script> + <![CDATA[ + import mx.effects.easing.*; + ]]> + </fx:Script> + + <fx:Declarations> + <mx:Sequence id="movePauseMove"> + <mx:Move xBy="150" duration="2000" easingFunction="Bounce.easeOut"/> + <mx:Pause duration="2000"/> + <mx:Move xBy="-150" duration="2000" easingFunction="Bounce.easeIn"/> + </mx:Sequence> + </fx:Declarations> + + <mx:Panel title="Sequence Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + text="Click the logo to start the Sequence effect. The effect pauses for 2 seconds between moves."/> + + <mx:Image source="@Embed(source='assets/ApacheFlexLogo.png')" + width="50%" height="50%" + mouseDownEffect="{movePauseMove}"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/SimpleEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/SimpleEffectExample.mxml b/tourdeflexmodules/src/mx/effects/SimpleEffectExample.mxml new file mode 100755 index 0000000..811868b --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/SimpleEffectExample.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 the Effect class. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Script> + <![CDATA[ + + import mx.controls.Alert; + + // Event handler for the effectEnd event. + private function endEffectHandler():void { + Alert.show("Effect Ended!"); + } + + // Event handler for the reset button. + private function resetHandler():void { + expand.end(); + img.width=30; + img.height=60; + button1.enabled=true; + } + ]]> + </fx:Script> + + + <fx:Declarations> + <mx:Resize id="expand" target="{img}" widthTo="100" heightTo="200" + duration="10000" effectEnd="endEffectHandler()"/> + </fx:Declarations> + + <mx:Panel title="Resize Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + text="Use the Button controls to control the Resize effect."/> + + <mx:Image id="img" width="30" height="60" + source="@Embed(source='assets/ApacheFlexLogo.png')"/> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/SimpleTweenEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/SimpleTweenEffectExample.mxml b/tourdeflexmodules/src/mx/effects/SimpleTweenEffectExample.mxml new file mode 100755 index 0000000..55c20fc --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/SimpleTweenEffectExample.mxml @@ -0,0 +1,76 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/SoundEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/SoundEffectExample.mxml b/tourdeflexmodules/src/mx/effects/SoundEffectExample.mxml new file mode 100755 index 0000000..e93d095 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/SoundEffectExample.mxml @@ -0,0 +1,40 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Declarations> + <mx:SoundEffect id="mySounds" source="@Embed(source='./assets/ping.mp3')"/> + </fx:Declarations> + + <mx:Panel title="Sound Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Label width="100%" + text="Click on the logo to hear the sound effect."/> + + <mx:Image id="flex" source="@Embed(source='assets/ApacheFlexLogo.png')" + width="50%" height="50%" + mouseDownEffect="{mySounds}"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/WipeDownExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/WipeDownExample.mxml b/tourdeflexmodules/src/mx/effects/WipeDownExample.mxml new file mode 100755 index 0000000..6fd93b9 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/WipeDownExample.mxml @@ -0,0 +1,49 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Declarations> + <mx:WipeDown id="wipeOut" duration="1000"/> + <mx:WipeDown id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeDown Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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')" + width="50%" height="50%" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/WipeLeftExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/WipeLeftExample.mxml b/tourdeflexmodules/src/mx/effects/WipeLeftExample.mxml new file mode 100755 index 0000000..3ee0bf5 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/WipeLeftExample.mxml @@ -0,0 +1,49 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Declarations> + <mx:WipeLeft id="wipeOut" duration="1000"/> + <mx:WipeLeft id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeLeft Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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')" + width="50%" height="50%" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/WipeRightExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/WipeRightExample.mxml b/tourdeflexmodules/src/mx/effects/WipeRightExample.mxml new file mode 100755 index 0000000..8dc8e72 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/WipeRightExample.mxml @@ -0,0 +1,49 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Declarations> + <mx:WipeRight id="wipeOut" duration="1000"/> + <mx:WipeRight id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeRight Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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')" + width="50%" height="50%" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/WipeUpExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/WipeUpExample.mxml b/tourdeflexmodules/src/mx/effects/WipeUpExample.mxml new file mode 100755 index 0000000..acc2047 --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/WipeUpExample.mxml @@ -0,0 +1,49 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <fx:Declarations> + <mx:WipeUp id="wipeOut" duration="1000"/> + <mx:WipeUp id="wipeIn" duration="1000"/> + </fx:Declarations> + + <mx:Panel title="WipeUp Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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')" + width="50%" height="50%" + visible="{cb1.selected}" + hideEffect="{wipeOut}" showEffect="{wipeIn}"/> + + <mx:CheckBox id="cb1" label="visible" selected="true"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/ZoomEffectExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/ZoomEffectExample.mxml b/tourdeflexmodules/src/mx/effects/ZoomEffectExample.mxml new file mode 100755 index 0000000..95716bf --- /dev/null +++ b/tourdeflexmodules/src/mx/effects/ZoomEffectExample.mxml @@ -0,0 +1,59 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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="0.5" zoomHeightTo="0.5" zoomWidthFrom="0.25" zoomHeightFrom="0.25" /> + </fx:Declarations> + + <mx:Panel title="Zoom Effect Example" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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="0.25" scaleY="0.25" + rollOver="doZoom(event)" + rollOut="doZoom(event)"/> + + </mx:Panel> +</mx:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/assets/ApacheFlexLogo.png ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/assets/ApacheFlexLogo.png b/tourdeflexmodules/src/mx/effects/assets/ApacheFlexLogo.png new file mode 100644 index 0000000..4ff037f Binary files /dev/null and b/tourdeflexmodules/src/mx/effects/assets/ApacheFlexLogo.png differ http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/assets/OpenSans-Regular.ttf ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/assets/OpenSans-Regular.ttf b/tourdeflexmodules/src/mx/effects/assets/OpenSans-Regular.ttf new file mode 100644 index 0000000..db43334 Binary files /dev/null and b/tourdeflexmodules/src/mx/effects/assets/OpenSans-Regular.ttf differ http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/effects/assets/ping.mp3 ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/effects/assets/ping.mp3 b/tourdeflexmodules/src/mx/effects/assets/ping.mp3 new file mode 100644 index 0000000..2eb90ea Binary files /dev/null and b/tourdeflexmodules/src/mx/effects/assets/ping.mp3 differ http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/CurrencyFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/CurrencyFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/CurrencyFormatterExample.mxml new file mode 100755 index 0000000..37a085c --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/CurrencyFormatterExample.mxml @@ -0,0 +1,74 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/DateFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/DateFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/DateFormatterExample.mxml new file mode 100755 index 0000000..4442841 --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/DateFormatterExample.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 the DateFormatter. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/NumberFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/NumberFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/NumberFormatterExample.mxml new file mode 100755 index 0000000..bc64f8e --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/NumberFormatterExample.mxml @@ -0,0 +1,71 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/PhoneFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/PhoneFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/PhoneFormatterExample.mxml new file mode 100755 index 0000000..2f7aa5b --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/PhoneFormatterExample.mxml @@ -0,0 +1,70 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/SimpleFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/SimpleFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/SimpleFormatterExample.mxml new file mode 100755 index 0000000..ea05724 --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/SimpleFormatterExample.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 Formatter class. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/SwitchSymbolFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/SwitchSymbolFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/SwitchSymbolFormatterExample.mxml new file mode 100755 index 0000000..fa6e6f9 --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/SwitchSymbolFormatterExample.mxml @@ -0,0 +1,66 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/formatters/ZipCodeFormatterExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/formatters/ZipCodeFormatterExample.mxml b/tourdeflexmodules/src/mx/formatters/ZipCodeFormatterExample.mxml new file mode 100755 index 0000000..c38ccb6 --- /dev/null +++ b/tourdeflexmodules/src/mx/formatters/ZipCodeFormatterExample.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 ZipCodeFormatter. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/printing/AdvancedPrintDataGridExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/printing/AdvancedPrintDataGridExample.mxml b/tourdeflexmodules/src/mx/printing/AdvancedPrintDataGridExample.mxml new file mode 100755 index 0000000..cb85d1f --- /dev/null +++ b/tourdeflexmodules/src/mx/printing/AdvancedPrintDataGridExample.mxml @@ -0,0 +1,107 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/printing/FormPrintFooter.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/printing/FormPrintFooter.mxml b/tourdeflexmodules/src/mx/printing/FormPrintFooter.mxml new file mode 100755 index 0000000..853f59f --- /dev/null +++ b/tourdeflexmodules/src/mx/printing/FormPrintFooter.mxml @@ -0,0 +1,34 @@ +<?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> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/printing/FormPrintHeader.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/printing/FormPrintHeader.mxml b/tourdeflexmodules/src/mx/printing/FormPrintHeader.mxml new file mode 100755 index 0000000..5285a93 --- /dev/null +++ b/tourdeflexmodules/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> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/printing/FormPrintView.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/printing/FormPrintView.mxml b/tourdeflexmodules/src/mx/printing/FormPrintView.mxml new file mode 100755 index 0000000..4701121 --- /dev/null +++ b/tourdeflexmodules/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> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/printing/PrintDataGridExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/printing/PrintDataGridExample.mxml b/tourdeflexmodules/src/mx/printing/PrintDataGridExample.mxml new file mode 100755 index 0000000..94ce408 --- /dev/null +++ b/tourdeflexmodules/src/mx/printing/PrintDataGridExample.mxml @@ -0,0 +1,145 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" 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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:DataGrid id="myDataGrid" dataProvider="{dgProvider}"> + <mx:columns> + <mx:DataGridColumn dataField="Index"/> + <mx:DataGridColumn dataField="Qty"/> + </mx:columns> + </mx:DataGrid> + + <mx:Text width="100%" + 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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/states/StatesExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/states/StatesExample.mxml b/tourdeflexmodules/src/mx/states/StatesExample.mxml new file mode 100755 index 0000000..04b5fc4 --- /dev/null +++ b/tourdeflexmodules/src/mx/states/StatesExample.mxml @@ -0,0 +1,59 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <!-- 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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/states/TransitionExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/states/TransitionExample.mxml b/tourdeflexmodules/src/mx/states/TransitionExample.mxml new file mode 100755 index 0000000..e93ada5 --- /dev/null +++ b/tourdeflexmodules/src/mx/states/TransitionExample.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 Transition class. --> +<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <!-- 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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <mx:Text width="100%" + 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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/validators/CreditCardValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/validators/CreditCardValidatorExample.mxml b/tourdeflexmodules/src/mx/validators/CreditCardValidatorExample.mxml new file mode 100755 index 0000000..161ccec --- /dev/null +++ b/tourdeflexmodules/src/mx/validators/CreditCardValidatorExample.mxml @@ -0,0 +1,71 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/validators/CurrencyValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/validators/CurrencyValidatorExample.mxml b/tourdeflexmodules/src/mx/validators/CurrencyValidatorExample.mxml new file mode 100755 index 0000000..0dbe21c --- /dev/null +++ b/tourdeflexmodules/src/mx/validators/CurrencyValidatorExample.mxml @@ -0,0 +1,48 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <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:Module> http://git-wip-us.apache.org/repos/asf/flex-examples/blob/9343d391/tourdeflexmodules/src/mx/validators/DateValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/tourdeflexmodules/src/mx/validators/DateValidatorExample.mxml b/tourdeflexmodules/src/mx/validators/DateValidatorExample.mxml new file mode 100755 index 0000000..8d1bbb3 --- /dev/null +++ b/tourdeflexmodules/src/mx/validators/DateValidatorExample.mxml @@ -0,0 +1,55 @@ +<?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:Module xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:mx="library://ns.adobe.com/flex/mx" + paddingBottom="0" paddingTop="0" paddingLeft="0" paddingRight="0" + height="100%" width="100%"> + + <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" + paddingBottom="10" paddingTop="10" paddingLeft="10" paddingRight="10" + height="100%" width="100%"> + + <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:Module>