2 Replies Latest reply on Jul 17, 2007 1:30 PM by Munka

    Offline User Form

    Munka
      Greetings flex community,

      I've been tasked with designing a user form that will be filled out offline (no net connection, no webserver, etc..) This form is for signing up for an e-newsletter. I desided to use Flex for this, however I've run into a bit of an issue. My goal is to have the form fields saved locally to an .xml file (<mx:Model source="enewsletter.xml" id="XMLFILE"/>). I've searched the forums and am lead to believe this may not be possible? Are there some imports that can be added to the <mx:Script></mx:Script> to allow this functionality?

      I'm fairly new to flex so forgive the noob'ness :) Here's the code I have so far, any corrections are also welcome and suggestions. Thanks in advance!

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[
      ]]>
      </mx:Script>
      <mx:Style source="theme.css"/>
      <mx:Model source="enewsletter.xml" id="XMLFILE"/>
      <mx:Panel width="640" height="480" layout="absolute" verticalCenter="-31" horizontalCenter="-1" id="ui_main" title="Sign Up for our E-Newsletter!" horizontalAlign="center" verticalAlign="middle" fontWeight="bold" backgroundAlpha="1.0" alpha="1.0" fontFamily="Arial" fontSize="12">

      <mx:Label x="33" y="196" text="Zipcode:" width="69"/>
      <mx:TextInput x="110" y="194" borderStyle="inset" borderColor="#000000" enabled="true" id="ZIP"/>

      <mx:Label x="33" y="313" text="Phone:" width="69"/>
      <mx:TextInput x="110" y="311" borderStyle="inset" borderColor="#000000" enabled="true" id="PHONENUM"/>

      <mx:Label x="35" y="373" text="E-Mail:" width="44"/>
      <mx:TextInput x="110" y="371" borderStyle="inset" borderColor="#000000" enabled="true" id="EMAIL"/>

      <mx:Label x="278" y="13" text="Last Name:" width="69"/>
      <mx:TextInput x="355" y="11" borderStyle="inset" borderColor="#000000" enabled="true" id="LastName"/>

      <mx:Label x="33" y="13" text="First Name:" width="69"/>
      <mx:TextInput x="110" y="11" borderColor="#000000" enabled="true" id="FirstName"/>

      <mx:Label x="33" y="128" text="Street / Mailing Address:" width="148"/>
      <mx:TextInput x="189" y="126" borderStyle="inset" borderColor="#000000" enabled="true" width="326" id="ADDRESS"/>

      <mx:Label x="303" y="164" text="State:" width="48"/>
      <mx:ComboBox x="355" y="161" id="STATE" enabled="true">
      <mx:dataProvider>
      <mx:Array>
      </mx:Array>
      </mx:dataProvider>
      </mx:ComboBox>

      <mx:Label x="33" y="161" text="City:" width="69"/>
      <mx:TextInput x="110" y="161" borderStyle="inset" borderColor="#000000" enabled="true" id="CITY"/>


      <mx:Label x="33" y="42" text="Do you wish to recieve mail about new vehicles and information, upcoming events and more?" width="577"/>
      <mx:Text x="33" y="97" text="Please enter your mailing information below if you selected Yes." width="577"/>
      <mx:Label x="33" y="227" text="Do you wish to recieve phone calls about new vehicles and information, upcoming events and more?" width="577"/>
      <mx:Text x="33" y="282" text="Please enter your phone number below if you selected Yes." width="577"/>
      <mx:Label x="33" y="342" text="Please enter your E-Mail Address to recieve our E-Newsletter." width="577"/>

      <mx:RadioButtonGroup id="radiogroup1"/>
      <mx:RadioButton x="54.0" y="71.0" label="YES" groupName="USPSMAIL" fontWeight="bold" id="YES1" enabled="true"/>
      <mx:RadioButton x="132" y="71" label="NO" groupName="USPSMAIL" fontWeight="bold" id="NO1" enabled="true"/>

      <mx:RadioButtonGroup id="radiogroup2"/>
      <mx:RadioButton x="54" y="256.0" label="YES" groupName="PHONE" fontWeight="bold" id="YES2" enabled="true"/>
      <mx:RadioButton x="132" y="256" label="NO" groupName="PHONE" fontWeight="bold" id="NO2" enabled="true"/>

      <mx:Button x="544" y="388" label="Submit" enabled="true" id="SUBMIT" click="XMLFILE"/>

      <mx:ControlBar>
      </mx:ControlBar>

      </mx:Panel>
      <mx:Text text="No purchase necessary to sign up, must be 18 years old or older. Copyright (c) 2007 Kendall Automotive Group." width="633" textAlign="center" horizontalCenter="0" verticalCenter="227.5" fontFamily="Arial" fontSize="10" color="#000000" height="21" fontStyle="italic" fontWeight="bold"/>
      <mx:SWFLoader width="640" horizontalCenter="-1" verticalCenter="-295" source="Untitled-6.swf" autoLoad="true"/>
      </mx:Application>
        • 1. Re: Offline User Form
          ntsiii Level 3
          I'm sorry, but writing to the local file system is forbidden by the security restrictions on both the browser, and especially, the Flash Player.

          Now, you CAN write to what is called a local SharedObject, which is kinda like a "cookie on steroids". Then on connection, write tht data to the server.

          And again, you might consider using AIR(Apollo), which is currently in beta. You write Flex code, but it uses a different rendering engine than the Flash Player,and can access local assets.

          Tracy
          • 2. Re: Offline User Form
            Munka Level 1
            Thank you for the reply nt, I'll look into AIR as a possible solution. Any words of wisdom about AIR?