Advertisement
Guest User

Contact Form

a guest
Sep 28th, 2011
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MXML 9.30 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <s:Group xmlns:s="library://ns.adobe.com/flex/spark"
  3.          xmlns:fx="http://ns.adobe.com/mxml/2009"
  4.          xmlns:ai="http://ns.adobe.com/ai/2009"
  5.          xmlns:d="http://ns.adobe.com/fxg/2008/dt"
  6.          xmlns:flm="http://ns.adobe.com/flame/2008"
  7.          xmlns:fc="http://ns.adobe.com/flashcatalyst/2009"
  8.          width="366" height="434"  creationComplete="init(event)" xmlns:mx="library://ns.adobe.com/flex/mx">
  9.    
  10.     <fx:Declarations>
  11.         <mx:EmailValidator id='email_validator'
  12.                            source="{email_input}"
  13.                            required="true"
  14.                            property="text"
  15.                            invalidCharError="Your e-mail address contains invalid characters."
  16.                            invalidDomainError= "The domain in your e-mail address is incorrectly formatted."
  17.                            invalidIPDomainError="The IP domain in your e-mail address is incorrectly formatted."
  18.                            invalidPeriodsInDomainError="The domain in your e-mail address has consecutive periods."
  19.                            missingPeriodInDomainError="The domain in your e-mail address is missing a period."
  20.                            missingUsernameError="The username in your e-mail address is missing."
  21.                            missingAtSignError="An at sign (@) is missing in your e-mail address."
  22.                            tooManyAtSignsError="Your e-mail address contains too many @ characters."
  23.                            />
  24.        
  25.        
  26.         <mx:Validator id="name_validator"
  27.                       required="true"
  28.                       source="{name_input}"
  29.                       property="text"
  30.                       />
  31.        
  32.         <mx:Validator id="phone_validator"
  33.                       required="true"
  34.                       source="{phone_number_input}"
  35.                       property="text"
  36.                       />
  37.        
  38.         <mx:Validator id="item_validator"
  39.                       required="true"
  40.                       source="{item_input}"
  41.                       property="text"
  42.                      />
  43.        
  44.     </fx:Declarations>
  45.    
  46.     <fx:Script>
  47.         <![CDATA[
  48.             import mx.controls.Alert;
  49.             import mx.events.FlexEvent;
  50.             import mx.rpc.events.ResultEvent;
  51.  
  52.             private var myValidators:Array;
  53.  
  54.             private function send_email():void
  55.             {
  56.                 var errors:Array = Validator.validateAll(myValidators);
  57.                 if (errors.length == 0) {
  58.                     trace('valid');
  59.                     post_message();
  60.                 }else{
  61.                     trace('invalid');
  62.                 }
  63.             }
  64.              
  65.             public function post_message():void
  66.             {
  67.                 // Variables to send along with upload
  68.                 var sendVars:URLVariables = new URLVariables();
  69.                     sendVars.email =    this.email_input.text;
  70.                 sendVars.name =         this.name_input.text;
  71.                 //sendVars.phone =          this.phone_number_input.text;
  72.                 //sendVars.phone2 =         this.secondary_phone_input.text;
  73.                 //sendVars.item =           this.item_input.text;
  74.                 sendVars.message = "phone: "+ this.phone_number_input.text +
  75.                                    "secondary phone: "+this.secondary_phone_input.text+
  76.                                    "item number: "+this.item_input.text;
  77.                                    
  78.                 var request:URLRequest = new URLRequest();
  79.                     request.url = 'email_service.php';
  80.                     request.data = sendVars;
  81.                     request.method = URLRequestMethod.POST;
  82.                
  83.                 var loader:URLLoader = new URLLoader(request);
  84.                     loader.addEventListener(Event.COMPLETE, onComplete);
  85.                     //loader.dataFormat = URLLoaderDataFormat.VARIABLES; is not working WHY?!
  86.                     loader.dataFormat = URLLoaderDataFormat.TEXT;
  87.                
  88.                 try
  89.                 {
  90.                     loader.load(request);
  91.                 }
  92.                 catch (event:Error)
  93.                 {
  94.                     trace('error');
  95.                 }
  96.             }
  97.            
  98.            
  99.             public function onComplete (event:Event):void{
  100.                 trace('result: '+event.target.data);
  101.                 Alert.show('PHP Response: '+event.target.data);
  102.                 if(event.target.data=='success'){
  103.                     currentState='thankyou';
  104.                 }else{
  105.                     Alert.show("Try angain, please","ERROR")
  106.                 }
  107.             }
  108.            
  109.            
  110.            
  111.             protected function init(event:FlexEvent):void
  112.             {
  113.                 myValidators = [email_validator, name_validator, phone_validator, item_validator ];
  114.             }
  115.            
  116.         ]]>
  117.        
  118.     </fx:Script>
  119.     <s:states>
  120.         <s:State name="order"/>
  121.         <s:State name="thankyou"/>
  122.     </s:states>
  123.    
  124.     <s:Rect id="rect1" alpha="1" radiusX="10.1549" radiusY="9.9993"
  125.             x.order="0.095" y.order="0.032" width.order="366.006" height.order="434.008"
  126.             x.thankyou="0" y.thankyou="0" width.thankyou="366" height.thankyou="92"
  127.             alpha.thankyou="0.7000000000000001">
  128.         <s:fill>
  129.             <s:SolidColor color="0xF7F7F7"/>
  130.         </s:fill>
  131.         <s:filters>
  132.             <s:DropShadowFilter includeIn="order" alpha="0.2" angle="45.0" blurX="4.0" blurY="4.0"
  133.                                 color="#000000" distance="4.0" hideObject="false" inner="false"
  134.                                 knockout="false" quality="2" strength="1"/>
  135.             <s:DropShadowFilter includeIn="thankyou" alpha="0.2" angle="45.0" blurX="4.0" blurY="4.0"
  136.                                 color="#000000" distance="4.0" hideObject="false" inner="false"
  137.                                 knockout="false" quality="2" strength="1"/>
  138.         </s:filters>
  139.     </s:Rect>
  140.     <s:RichText x="17" y="13" width="119" height="24" color="#CCCCCC" fontFamily="Earth Normal"
  141.                 fontSize="21" tabStops="S0 S50 S100 S150 S200 S250 S300 S350" text="ORDER">
  142.     </s:RichText>
  143.     <s:RichText d:id="4" d:userLabel="Name" includeIn="order" x="17" y="52" width="40" height="13"
  144.                 ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
  145.                 lineHeight="14.4" tabStops="S0" text="Name" textAlpha="0.7" flm:variant="1"
  146.                 whiteSpaceCollapse="preserve"/>
  147.     <s:RichText d:id="5" d:userLabel="Email" includeIn="order" x="17" y="87" width="39" height="13"
  148.                 ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
  149.                 lineHeight="14.4" tabStops="S0" text="Email" textAlpha="0.7" flm:variant="2"
  150.                 whiteSpaceCollapse="preserve"/>
  151.     <s:RichText d:id="6" d:userLabel="Primary Phone:" includeIn="order" x="17" y="122" width="88"
  152.                 height="13" ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
  153.                 fontSize="12" lineHeight="14.4" tabStops="S0 S50" text="Primary Phone:"
  154.                 textAlpha="0.7" flm:variant="3" whiteSpaceCollapse="preserve"/>
  155.     <s:RichText d:id="7" d:userLabel="Secondary Phone " includeIn="order" x="17" y="157" width="105"
  156.                 height="13" ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
  157.                 lineHeight="14.4" tabStops="S0 S50 S100" text="Secondary Phone " textAlpha="0.7"
  158.                 flm:variant="4" whiteSpaceCollapse="preserve"/>
  159.     <s:RichText d:id="8" d:userLabel="Order" includeIn="order" x="62" y="194" width="35" height="13"
  160.                 ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
  161.                 lineHeight="14.4" tabStops="S0" text="Order" textAlpha="0.7" flm:variant="5"
  162.                 whiteSpaceCollapse="preserve"/>
  163.     <s:RichText d:id="9" d:userLabel="Please list the brand, item/s and quantities" includeIn="order"
  164.                 x="95" y="194" width="261" height="14" ai:aa="2" color="#464646" columnCount="1"
  165.                 fontFamily="Arial" fontSize="12" lineHeight="14.4"
  166.                 tabStops="S0 S50 S100 S150 S200 S250 "
  167.                 text="(please list the brand, item/s and quantities)" textAlpha="0.3"
  168.                 flm:variant="6" whiteSpaceCollapse="preserve"/>
  169.     <s:RichText d:id="8" d:userLabel="Order" includeIn="order" x="17" y="194" width="51" height="13"
  170.                 ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
  171.                 fontSize="12" lineHeight="14.4" tabStops="S0 S50" textAlpha="0.7" flm:variant="5"
  172.                 whiteSpaceCollapse="preserve">
  173.         <s:content><s:p><s:span>Enquiry</s:span><s:span fontFamily="Arial Bold" textAlpha="0.4">/</s:span></s:p></s:content>
  174.     </s:RichText>
  175.     <s:TextInput id="name_input" includeIn="order" x="59" y="45" />
  176.     <s:TextInput id="email_input" includeIn="order" x="59" y="81" />
  177.     <s:TextInput id="secondary_phone_input" includeIn="order" x="122" y="154"
  178.                  />
  179.    
  180.     <s:TextInput id="phone_number_input" includeIn="order" x="122" y="118"
  181.                  />
  182.    
  183.     <s:TextInput id="item_input" includeIn="order" x="17" y="216"
  184.                 />
  185.    
  186.     <s:RichText includeIn="thankyou" x="17" y="46" width="242" height="29" alpha="0.5"
  187.                 color="#464646" fontFamily="Arial" fontSize="12"
  188.                 tabStops="S0 S50 S100 S150 S200" whiteSpaceCollapse="preserve">
  189.        
  190.         <s:content><s:p><s:span><![CDATA[Thankyou for your order/enquiry! ]]></s:span></s:p><s:p><s:span><![CDATA[Earthsk8 will be in contact with you shortly ]]></s:span></s:p></s:content>
  191.     </s:RichText>
  192.     <s:RichText includeIn="order" x="17" y="407" width="71" height="12" color="#464646"
  193.                 fontFamily="Arial" fontSize="10" tabStops="S0 S50 S100" text="*required fields"
  194.                 textAlpha="0.6"/>
  195.     <s:RichText includeIn="order" x="52" y="45" width="9" height="8" alpha="0.3" color="#464646"
  196.                 fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
  197.     <s:RichText includeIn="order" x="52" y="81" width="9" height="8" alpha="0.3" color="#464646"
  198.                 fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
  199.     <s:RichText includeIn="order" x="114" y="118" width="9" height="8" alpha="0.3" color="#464646"
  200.                 fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
  201.     <s:RichText includeIn="order" x="9" y="216" width="9" height="8" alpha="0.3" color="#464646"
  202.                 fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
  203.    
  204.     <s:Button id='send_button' includeIn="order" x="282" y="403" click="send_email()"
  205.               />
  206.     <s:transitions>
  207.         <s:Transition fromState="order" interruptionBehavior="stop" toState="thankyou">
  208.             <s:Parallel>
  209.                 <s:Parallel target="{rect1}">
  210.                     <s:Animate duration="750">
  211.                         <s:SimpleMotionPath property="width"/>
  212.                         <s:SimpleMotionPath property="height"/>
  213.                     </s:Animate>
  214.                     <s:Fade duration="750"/>
  215.                 </s:Parallel>
  216.             </s:Parallel>
  217.         </s:Transition>
  218.     </s:transitions>
  219.     <fx:Private>
  220.     <fc:Guide x="17"/>
  221.     <fc:Guide x="0"/>
  222.     <fc:Guide x="366"/>
  223.     <fc:Guide y="0"/>
  224.     <fc:Guide y="45"/>
  225.     </fx:Private>
  226. </s:Group>
  227.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement