2 Replies Latest reply on Sep 1, 2009 5:47 AM by Revlex

    exporting an XML file

    Revlex Level 1

      hi all,

       

      i have a little problem, my problem is this one: I'm trying to save my own xml file to the client. the xml is created in the app im building with this code:

       

      <?xml version="1.0" encoding="utf-8"?>
      <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/halo" minWidth="1024" minHeight="768">

       

      <fx:Script>
          <![CDATA[
              import mx.utils.XMLUtil;
              import flashx.textLayout.conversion.TextFilter;
              import mx.controls.Alert;
              import mx.utils.ObjectUtil;
             
              private var the_image:FileReference = new FileReference;
              private var taxt:TextField = new TextField();
              private var new_xml:XML = new XML();
              private var filter:TextFilter = new TextFilter();
             
              private function xml_save(e:MouseEvent):void
              {
                  new_xml = <info>
                          <Titel>
                              {titel.text}
                          </Titel>
                          <Kop>
                              {kop.text}
                          </Kop>
                          <Tekst_stuk>
                          {tekst_stuk.text}
                          </Tekst_stuk>
                      </info>;
                     
                      new_xml = filter.export(new_xml.ConversionType.XML_TYPE);
              }
             
              private function plaatje(e:MouseEvent):void
              {
                  var arr:Array = [];
                  arr.push(new FileFilter("Images", ".jpeg;*.jpg;*.png"));
                  the_image.browse(arr);
                  the_image.addEventListener(Event.SELECT, selected);

       

              }

       

              private function selected(E:Event):void
              {
                  the_image.load();
                  the_image.addEventListener(Event.COMPLETE, image_done);
              }

       

              private function image_done(E:Event):void
              {
                  img.source = the_image.data;
              }
          ]]>
      </fx:Script>

       


      <mx:ControlBar>
          <s:Button label="Picture" id="btn" enabled="true" click="plaatje(event);"/>
          <s:Button label="Save" enabled="true" id="save_xml" click="xml_save(event);"/>
      </mx:ControlBar>
          <mx:Image x="594" y="23" id="img"/>
          <s:TextInput x="47" y="122" id="titel" text="Titel" enabled="true"/>
          <s:TextArea x="48" y="209" editable="true" enabled="true" text="Stukje" id="tekst_stuk"/>
          <s:TextInput x="47" y="164" enabled="true" text="Kop" id="kop"/>

       

      </s:Application>

       

      my question is: how can i export the xml generated here above to an .xml file on the client computer?