3 Replies Latest reply on Aug 21, 2009 1:36 AM by c_luckett

    Create XML file dynamically from textInput fields




      I'm very new to Flex and trying to create an application that creates XML files on the users' local computer, based on a users input into textInput fields.


      At the moment I'm having trouble finding how to dyamically create an external XML file at all, ideally when the user pushes a button a browseForSave dialog box will open allowing the user to select somewhere on their hard drive to create the XML file.


      Can anyone give me a hint what direction I should be heading in?



        • 1. Re: Create XML file dynamically from textInput fields
          kkc_mca Level 2

          flex application cannot access the local resources

          your will get a sandbox violation


          check shared object concept


          if this post answers your question or help. Please mark it as such

          1 person found this helpful
          • 2. Re: Create XML file dynamically from textInput fields
            Gregory Lafrance Level 6

            If this post answered your question or helped, please mark it as such.


            You could use a SharedObject for small files, but in general Flex does not have access to the local hard drive.


            <?xml version="1.0"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                  public var mySO:SharedObject;
                  public function init():void{
                    mySO = SharedObject.getLocal("mydata");
                      var xml:XML = mySO.data.myData;
                      fname.text = xml.fname;
                      lname.text = xml.lname;
                      email.text = xml.email;

                  private function storeData():void{
                    var xml:XML =
                    if(fname.text != ""){
                    if(lname.text != ""){
                    if(email.text != ""){
                    mySO.data.myData = xml;
                  private function resetData():void{
                    fname.text = "";
                    lname.text = ""
                    email.text = "";
                <mx:FormItem label="First Name:">
                  <mx:TextInput id="fname"/>
                <mx:FormItem label="Last Name:">
                  <mx:TextInput id="lname"/>
                <mx:FormItem label="Email:">
                  <mx:TextInput id="email"/>
              <mx:Button label="Store Data" click="storeData()"/>
              <mx:Button label="Reload Stored Data" click="init()"/>
              <mx:Button label="Delete Stored Data" click="resetData()"/>

            • 3. Re: Create XML file dynamically from textInput fields
              c_luckett Level 1

              Cheers guys,


              That'll be why I'm not finding any similar examples, i'll try looking at some other language!