Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <s:Group xmlns:s="library://ns.adobe.com/flex/spark"
- xmlns:fx="http://ns.adobe.com/mxml/2009"
- xmlns:ai="http://ns.adobe.com/ai/2009"
- xmlns:d="http://ns.adobe.com/fxg/2008/dt"
- xmlns:flm="http://ns.adobe.com/flame/2008"
- xmlns:fc="http://ns.adobe.com/flashcatalyst/2009"
- width="366" height="434" creationComplete="init(event)" xmlns:mx="library://ns.adobe.com/flex/mx">
- <fx:Declarations>
- <mx:EmailValidator id='email_validator'
- source="{email_input}"
- required="true"
- property="text"
- invalidCharError="Your e-mail address contains invalid characters."
- invalidDomainError= "The domain in your e-mail address is incorrectly formatted."
- invalidIPDomainError="The IP domain in your e-mail address is incorrectly formatted."
- invalidPeriodsInDomainError="The domain in your e-mail address has consecutive periods."
- missingPeriodInDomainError="The domain in your e-mail address is missing a period."
- missingUsernameError="The username in your e-mail address is missing."
- missingAtSignError="An at sign (@) is missing in your e-mail address."
- tooManyAtSignsError="Your e-mail address contains too many @ characters."
- />
- <mx:Validator id="name_validator"
- required="true"
- source="{name_input}"
- property="text"
- />
- <mx:Validator id="phone_validator"
- required="true"
- source="{phone_number_input}"
- property="text"
- />
- <mx:Validator id="item_validator"
- required="true"
- source="{item_input}"
- property="text"
- />
- </fx:Declarations>
- <fx:Script>
- <![CDATA[
- import mx.controls.Alert;
- import mx.events.FlexEvent;
- import mx.rpc.events.ResultEvent;
- private var myValidators:Array;
- private function send_email():void
- {
- var errors:Array = Validator.validateAll(myValidators);
- if (errors.length == 0) {
- trace('valid');
- post_message();
- }else{
- trace('invalid');
- }
- }
- public function post_message():void
- {
- // Variables to send along with upload
- var sendVars:URLVariables = new URLVariables();
- sendVars.email = this.email_input.text;
- sendVars.name = this.name_input.text;
- //sendVars.phone = this.phone_number_input.text;
- //sendVars.phone2 = this.secondary_phone_input.text;
- //sendVars.item = this.item_input.text;
- sendVars.message = "phone: "+ this.phone_number_input.text +
- "secondary phone: "+this.secondary_phone_input.text+
- "item number: "+this.item_input.text;
- var request:URLRequest = new URLRequest();
- request.url = 'email_service.php';
- request.data = sendVars;
- request.method = URLRequestMethod.POST;
- var loader:URLLoader = new URLLoader(request);
- loader.addEventListener(Event.COMPLETE, onComplete);
- //loader.dataFormat = URLLoaderDataFormat.VARIABLES; is not working WHY?!
- loader.dataFormat = URLLoaderDataFormat.TEXT;
- try
- {
- loader.load(request);
- }
- catch (event:Error)
- {
- trace('error');
- }
- }
- public function onComplete (event:Event):void{
- trace('result: '+event.target.data);
- Alert.show('PHP Response: '+event.target.data);
- if(event.target.data=='success'){
- currentState='thankyou';
- }else{
- Alert.show("Try angain, please","ERROR")
- }
- }
- protected function init(event:FlexEvent):void
- {
- myValidators = [email_validator, name_validator, phone_validator, item_validator ];
- }
- ]]>
- </fx:Script>
- <s:states>
- <s:State name="order"/>
- <s:State name="thankyou"/>
- </s:states>
- <s:Rect id="rect1" alpha="1" radiusX="10.1549" radiusY="9.9993"
- x.order="0.095" y.order="0.032" width.order="366.006" height.order="434.008"
- x.thankyou="0" y.thankyou="0" width.thankyou="366" height.thankyou="92"
- alpha.thankyou="0.7000000000000001">
- <s:fill>
- <s:SolidColor color="0xF7F7F7"/>
- </s:fill>
- <s:filters>
- <s:DropShadowFilter includeIn="order" alpha="0.2" angle="45.0" blurX="4.0" blurY="4.0"
- color="#000000" distance="4.0" hideObject="false" inner="false"
- knockout="false" quality="2" strength="1"/>
- <s:DropShadowFilter includeIn="thankyou" alpha="0.2" angle="45.0" blurX="4.0" blurY="4.0"
- color="#000000" distance="4.0" hideObject="false" inner="false"
- knockout="false" quality="2" strength="1"/>
- </s:filters>
- </s:Rect>
- <s:RichText x="17" y="13" width="119" height="24" color="#CCCCCC" fontFamily="Earth Normal"
- fontSize="21" tabStops="S0 S50 S100 S150 S200 S250 S300 S350" text="ORDER">
- </s:RichText>
- <s:RichText d:id="4" d:userLabel="Name" includeIn="order" x="17" y="52" width="40" height="13"
- ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
- lineHeight="14.4" tabStops="S0" text="Name" textAlpha="0.7" flm:variant="1"
- whiteSpaceCollapse="preserve"/>
- <s:RichText d:id="5" d:userLabel="Email" includeIn="order" x="17" y="87" width="39" height="13"
- ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
- lineHeight="14.4" tabStops="S0" text="Email" textAlpha="0.7" flm:variant="2"
- whiteSpaceCollapse="preserve"/>
- <s:RichText d:id="6" d:userLabel="Primary Phone:" includeIn="order" x="17" y="122" width="88"
- height="13" ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
- fontSize="12" lineHeight="14.4" tabStops="S0 S50" text="Primary Phone:"
- textAlpha="0.7" flm:variant="3" whiteSpaceCollapse="preserve"/>
- <s:RichText d:id="7" d:userLabel="Secondary Phone " includeIn="order" x="17" y="157" width="105"
- height="13" ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
- lineHeight="14.4" tabStops="S0 S50 S100" text="Secondary Phone " textAlpha="0.7"
- flm:variant="4" whiteSpaceCollapse="preserve"/>
- <s:RichText d:id="8" d:userLabel="Order" includeIn="order" x="62" y="194" width="35" height="13"
- ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
- lineHeight="14.4" tabStops="S0" text="Order" textAlpha="0.7" flm:variant="5"
- whiteSpaceCollapse="preserve"/>
- <s:RichText d:id="9" d:userLabel="Please list the brand, item/s and quantities" includeIn="order"
- x="95" y="194" width="261" height="14" ai:aa="2" color="#464646" columnCount="1"
- fontFamily="Arial" fontSize="12" lineHeight="14.4"
- tabStops="S0 S50 S100 S150 S200 S250 "
- text="(please list the brand, item/s and quantities)" textAlpha="0.3"
- flm:variant="6" whiteSpaceCollapse="preserve"/>
- <s:RichText d:id="8" d:userLabel="Order" includeIn="order" x="17" y="194" width="51" height="13"
- ai:aa="2" alpha="0.8" color="#464646" columnCount="1" fontFamily="Arial"
- fontSize="12" lineHeight="14.4" tabStops="S0 S50" textAlpha="0.7" flm:variant="5"
- whiteSpaceCollapse="preserve">
- <s:content><s:p><s:span>Enquiry</s:span><s:span fontFamily="Arial Bold" textAlpha="0.4">/</s:span></s:p></s:content>
- </s:RichText>
- <s:TextInput id="name_input" includeIn="order" x="59" y="45" />
- <s:TextInput id="email_input" includeIn="order" x="59" y="81" />
- <s:TextInput id="secondary_phone_input" includeIn="order" x="122" y="154"
- />
- <s:TextInput id="phone_number_input" includeIn="order" x="122" y="118"
- />
- <s:TextInput id="item_input" includeIn="order" x="17" y="216"
- />
- <s:RichText includeIn="thankyou" x="17" y="46" width="242" height="29" alpha="0.5"
- color="#464646" fontFamily="Arial" fontSize="12"
- tabStops="S0 S50 S100 S150 S200" whiteSpaceCollapse="preserve">
- <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>
- </s:RichText>
- <s:RichText includeIn="order" x="17" y="407" width="71" height="12" color="#464646"
- fontFamily="Arial" fontSize="10" tabStops="S0 S50 S100" text="*required fields"
- textAlpha="0.6"/>
- <s:RichText includeIn="order" x="52" y="45" width="9" height="8" alpha="0.3" color="#464646"
- fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
- <s:RichText includeIn="order" x="52" y="81" width="9" height="8" alpha="0.3" color="#464646"
- fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
- <s:RichText includeIn="order" x="114" y="118" width="9" height="8" alpha="0.3" color="#464646"
- fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
- <s:RichText includeIn="order" x="9" y="216" width="9" height="8" alpha="0.3" color="#464646"
- fontFamily="Arial" fontSize="12" tabStops="S0" text="*"/>
- <s:Button id='send_button' includeIn="order" x="282" y="403" click="send_email()"
- />
- <s:transitions>
- <s:Transition fromState="order" interruptionBehavior="stop" toState="thankyou">
- <s:Parallel>
- <s:Parallel target="{rect1}">
- <s:Animate duration="750">
- <s:SimpleMotionPath property="width"/>
- <s:SimpleMotionPath property="height"/>
- </s:Animate>
- <s:Fade duration="750"/>
- </s:Parallel>
- </s:Parallel>
- </s:Transition>
- </s:transitions>
- <fx:Private>
- <fc:Guide x="17"/>
- <fc:Guide x="0"/>
- <fc:Guide x="366"/>
- <fc:Guide y="0"/>
- <fc:Guide y="45"/>
- </fx:Private>
- </s:Group>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement