http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/modules/ModuleExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/modules/ModuleExample.mxml b/TourDeFlex/TourDeFlex3/src/spark/modules/ModuleExample.mxml new file mode 100644 index 0000000..3ef1105 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/modules/ModuleExample.mxml @@ -0,0 +1,80 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <fx:Script> + <![CDATA[ + + private function loadModule(title:String, url:String):void + { + var p:ModulePanel = new ModulePanel(); + p.title = title; + p.url = url; + hBox.addChild(p); + } + + ]]> + </fx:Script> + + <fx:Declarations> + <fx:Component className="ModulePanel"> + <s:Panel> + <fx:Script> + <![CDATA[ + [Bindable] + public var url:String; + ]]> + </fx:Script> + + <s:layout> + <s:VerticalLayout horizontalAlign="center" /> + </s:layout> + + <mx:ModuleLoader id="ml" url="{url}" width="100%" height="100%"> + <mx:unload> + if(parent != null) + { + parent.removeChild(this); + } + </mx:unload> + </mx:ModuleLoader> + <mx:ControlBar> + <s:Button label="unload" click="ml.unloadModule()"/> + </mx:ControlBar> + </s:Panel> + </fx:Component> + </fx:Declarations> + + <s:layout> + <s:VerticalLayout horizontalAlign="center"/> + </s:layout> + + <mx:ApplicationControlBar dock="true" fillColors="[0x000000,0x323232]" fillAlphas="[1,1]" horizontalAlign="center"> + <s:Button label="Load Module 1" click="loadModule('module 1', 'Module1.swf')"/> + <s:Button label="Load Module 2" click="loadModule('module 2', 'Module2.swf')"/> + </mx:ApplicationControlBar> + + <mx:HBox id="hBox" /> + +</s:Application> \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/modules/TDFGradientBackgroundSkin.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/modules/TDFGradientBackgroundSkin.mxml b/TourDeFlex/TourDeFlex3/src/spark/modules/TDFGradientBackgroundSkin.mxml new file mode 100644 index 0000000..553aee3 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/modules/TDFGradientBackgroundSkin.mxml @@ -0,0 +1,49 @@ +<?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. + +--> +<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:mx="library://ns.adobe.com/flex/mx" + xmlns:s="library://ns.adobe.com/flex/spark"> + + <fx:Metadata> + [HostComponent("spark.components.Application")] + </fx:Metadata> + + <s:states> + <s:State name="normal" /> + <s:State name="disabled" /> + </s:states> + + <s:layout> + <s:BasicLayout /> + </s:layout> + + <s:Rect id="bg" width="100%" height="100%"> + <s:fill> + <s:LinearGradient rotation="90"> + <s:entries> + <s:GradientEntry color="0x000000" ratio="0.00" /> + <s:GradientEntry color="0x323232" ratio="1.0" /> + </s:entries> + </s:LinearGradient> + </s:fill> + </s:Rect> + + <s:Group id="contentGroup" left="0" right="0" top="0" bottom="0" /> +</s:SparkSkin> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop1Example.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop1Example.mxml b/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop1Example.mxml new file mode 100644 index 0000000..d849d97 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop1Example.mxml @@ -0,0 +1,62 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <fx:Declarations> + <s:ArrayList id="arr1"> + <fx:String>Orange</fx:String> + <fx:String>Apple</fx:String> + <fx:String>Pear</fx:String> + </s:ArrayList> + + <s:ArrayList id="arr2"> + <fx:String>Banana</fx:String> + </s:ArrayList> + </fx:Declarations> + + <s:Panel title="Drag and Drop Samples" + width="600" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:HorizontalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <s:List allowMultipleSelection="true" dropEnabled="true" dragEnabled="true" dragMoveEnabled="true" + dataProvider="{arr1}"/> + + <s:Label text="Drag Items between lists" color="0x000000"/> + + <s:List allowMultipleSelection="true" dropEnabled="true" dragEnabled="true" dragMoveEnabled="true" + dataProvider="{arr2}"/> + </s:Panel> + +</s:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop2Example.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop2Example.mxml b/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop2Example.mxml new file mode 100644 index 0000000..241074b --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/other/DragAndDrop2Example.mxml @@ -0,0 +1,80 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <fx:Script> + <![CDATA[ + import mx.managers.DragManager; + ]]> + </fx:Script> + + <fx:Declarations> + <s:ArrayList id="arr1"> + <fx:String>Orange</fx:String> + <fx:String>Apple</fx:String> + <fx:String>Pear</fx:String> + <fx:String>Banana</fx:String> + </s:ArrayList> + </fx:Declarations> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <s:Panel title="Fruit" height="100%" color="0x000000" borderAlpha="0.15"> + <s:List height="100%" dragEnabled="true" color="0x000000" dataProvider="{arr1}" /> + </s:Panel> + + <s:Panel id="fruitDetails" title="drag fruit here" width="600" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:VerticalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <s:dragEnter> + if (event.dragSource.hasFormat('itemsByIndex')) + { + var dropTarget:Panel = event.currentTarget as Panel; + DragManager.acceptDragDrop(dropTarget); + } + </s:dragEnter> + <s:dragOver> + + </s:dragOver> + <s:dragDrop> + var data:Object = event.dragSource.dataForFormat('itemsByIndex'); + var p:Panel = new Panel(); + p.title = new String(data); + p.percentWidth = 100; + p.percentHeight = 25; + p.setStyle("color","black"); + fruitDetails.addElement(p); + </s:dragDrop> + </s:Panel> + +</s:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/other/FilterExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/other/FilterExample.mxml b/TourDeFlex/TourDeFlex3/src/spark/other/FilterExample.mxml new file mode 100644 index 0000000..a6e4822 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/other/FilterExample.mxml @@ -0,0 +1,96 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html" + creationComplete="init()"> + + <fx:Script> + <![CDATA[ + + private var time:Timer; + private var count:int = 0; + + private function init():void{ + time = new Timer(1000,0); + time.addEventListener(TimerEvent.TIMER,timeHandler); + time.start(); + + } + + private function timeHandler(ev:TimerEvent):void{ + count ++; + dynamicText.text = String(count); + } + + private function filterHandler(ev:MouseEvent):void{ + var filterArr:Array = []; + + blurBox.selected ? filterArr.push(blur): null; + glowBox.selected ? filterArr.push(glow): null; + shadowBox.selected? filterArr.push(dropShadow): null; + bevelBox.selected ? filterArr.push(bevel): null; + + textSample.filters = filterArr; + dynamicText.filters = filterArr; + } + ]]> + </fx:Script> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <fx:Declarations> + <!--filters--> + <s:GlowFilter id="glow" blurX="12" blurY="12" color="#88AEF7" quality="2" strength="1"/> + <s:BlurFilter id="blur" blurX="4" blurY="4" quality="2" /> + <s:DropShadowFilter id="dropShadow" alpha="0.35" blurX="6" blurY="6" distance="6" color="#000000" angle="90" /> + <s:BevelFilter id="bevel" angle="45" blurX="0.5" blurY="0.5" distance="4" strength="0.7" highlightAlpha="0.7" shadowAlpha="0.7" /> + </fx:Declarations> + + <s:Panel title="Filters Samples" + width="600" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:VerticalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <s:Label id="textSample" text="SAMPLE TEXT" color="0x000000" + fontWeight="bold" fontSize="40" filters="{[bevel]}" /> + + <s:HGroup width="100%" color="#323232" horizontalAlign="center"> + <s:CheckBox id="blurBox" label="Blur" click="filterHandler(event)" /> + <s:CheckBox id="glowBox" label="Glow" click="filterHandler(event)" /> + <s:CheckBox id="shadowBox" label="Drop Shadow" click="filterHandler(event)" /> + <s:CheckBox id="bevelBox" label="Bevel" selected="true" click="filterHandler(event)" /> + </s:HGroup> + + <s:Label id="dynamicText" text="0" color="#323232" fontSize="18" filters="{[bevel]}" /> + + </s:Panel> + +</s:Application> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/validators/DateValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/validators/DateValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/spark/validators/DateValidatorExample.mxml new file mode 100644 index 0000000..6bce0e6 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/validators/DateValidatorExample.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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <fx:Script> + <![CDATA[ + import mx.controls.Alert; + ]]> + </fx:Script> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <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> + + <s:Panel title="DateValidator Example" width="600" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:HorizontalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <mx:Form color="0x323232"> + <mx:FormItem label="Enter date of birth (mm/dd/yyyy): "> + <s:TextInput id="dob" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <s:Button id="myButton" label="Validate" /> + </mx:FormItem> + </mx:Form> + + </s:Panel> + +</s:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/validators/EmailValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/validators/EmailValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/spark/validators/EmailValidatorExample.mxml new file mode 100644 index 0000000..a5adaa6 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/validators/EmailValidatorExample.mxml @@ -0,0 +1,65 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <fx:Script> + <![CDATA[ + import mx.controls.Alert; + ]]> + </fx:Script> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <fx:Declarations> + <mx:EmailValidator source="{email}" property="text" + trigger="{myButton}" triggerEvent="click" + valid="Alert.show('Validation Succeeded!');"/> + </fx:Declarations> + + + <s:Panel title="EmailValidator Example" width="600" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:HorizontalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <mx:Form color="0x323232"> + <mx:FormItem label="Enter an e-mail address: "> + <s:TextInput id="email" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <s:Button id="myButton" label="Validate" /> + </mx:FormItem> + </mx:Form> + + </s:Panel> + +</s:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/validators/NumberValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/validators/NumberValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/spark/validators/NumberValidatorExample.mxml new file mode 100644 index 0000000..76da726 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/validators/NumberValidatorExample.mxml @@ -0,0 +1,84 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <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> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <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> + + <s:Panel title="NumberValidator Example" width="600" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:HorizontalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <mx:Form color="0x323232"> + <mx:FormItem label="Enter number:"> + <s:TextInput id="inputVal" text="" width="50%"/> + </mx:FormItem> + + <mx:FormItem label="Formatted number (precision=4): "> + <s:Label id="formattedNumber" /> + </mx:FormItem> + + <mx:FormItem> + <s:Button label="Validate and Format" click="Format();"/> + </mx:FormItem> + </mx:Form> + + </s:Panel> + +</s:Application> http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f5d071b3/TourDeFlex/TourDeFlex3/src/spark/validators/RegExpValidatorExample.mxml ---------------------------------------------------------------------- diff --git a/TourDeFlex/TourDeFlex3/src/spark/validators/RegExpValidatorExample.mxml b/TourDeFlex/TourDeFlex3/src/spark/validators/RegExpValidatorExample.mxml new file mode 100644 index 0000000..c704718 --- /dev/null +++ b/TourDeFlex/TourDeFlex3/src/spark/validators/RegExpValidatorExample.mxml @@ -0,0 +1,101 @@ +<?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. + +--> +<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" + xmlns:s="library://ns.adobe.com/flex/spark" + xmlns:mx="library://ns.adobe.com/flex/mx" + skinClass="TDFGradientBackgroundSkin" + viewSourceURL="srcview/index.html"> + + <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="x"; + for (var i:uint = 0; i < eventObj.results.length; i++) + { + xResult = eventObj.results[i]; + reResults.text=reResults.text + xResult.matchedIndex + " " + xResult.matchedString; + } + } + else + { + reResults.text=""; + } + } + ]]> + </fx:Script> + + <s:layout> + <s:HorizontalLayout verticalAlign="middle" horizontalAlign="center" /> + </s:layout> + + <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> + + <s:Panel title="RegExpValidator Example" width="620" height="100%" + color="0x000000" + borderAlpha="0.15"> + + <s:layout> + <s:VerticalLayout horizontalAlign="center" + paddingLeft="10" paddingRight="10" + paddingTop="10" paddingBottom="10"/> + </s:layout> + + <s:Label width="100%" color="0x323232" text="Instructions:"/> + <s:Label width="100%" color="0x323232" text="1. Enter text to search. By default, enter a string containing the letters ABC in sequence followed by any digit."/> + <s:Label width="100%" color="0x323232" text="2. Enter the regular expression. By default, enter ABC\d."/> + <s:Label width="100%" color="0x323232" text="3. Click the Button control to trigger the validation."/> + <s:Label width="100%" color="0x323232" text="4. The results show the index in the text where the matching pattern begins, and the matching pattern. "/> + + <mx:Form color="0x323232"> + <mx:FormItem label="Enter text: "> + <s:TextInput id="regex_text" text="xxxxABC4xxx" width="100%"/> + </mx:FormItem> + + <mx:FormItem label="Enter regular expression: "> + <s:TextInput id="regex" text="ABC\d" width="100%"/> + </mx:FormItem> + + <mx:FormItem label="Results: "> + <s:TextInput id="reResults" width="100%"/> + </mx:FormItem> + + <mx:FormItem > + <s:Button id="myButton" label="Validate"/> + </mx:FormItem> + </mx:Form> + + </s:Panel> + +</s:Application>