Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <code>FileReference</code> class is safe for web browsers because it doesn't let you mess with users files without his consent.</p> <p>But, as you are using AIR you can use the <code>File</code> class that extends the <code>FileReference</code>.<br> Take a look at <a href="https://stackoverflow.com/questions/16122172/filereference-vs-file/16123731#16123731">this link</a> to understand the difference between them.</p> <p>Here's how you can use the <code>FileStream</code> class:</p> <pre><code>var file:File = new File().resolvePath("myFile.txt"); var stream:FileStream = new FileStream(); stream.open(file, FileMode.WRITE); stream.writeUTF("Hello world!"); stream.close(); </code></pre> <p>And you can read more about the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/filesystem/FileStream.html" rel="nofollow noreferrer">FileStream class</a> here.</p> <hr> <p><strong>EDIT</strong>: Looking at your current edited question I'd recommend you to load the xml data with a <code>File</code>/<code>FileReference</code>, something like the following:</p> <pre><code>private var file:File = new File(); private function loadFile():void { file.addEventListener(Event.COMPLETE, onFileComplete); file.resolvePath("data.xml"); // Or whatever your file is located file.load(); } private function saveFile():void { var writeStream:FileStream = new FileStream(); /* * FileMode.WRITE will truncate (empty) the file on open. * FileMode.APPEND will open the file "as is" and write in the end of it. */ writeStream.open(file, FileMode.WRITE); writeStream.writeBytes(data); // Any other write method can be used writeStream.close(); } private function onFileComplete(event:Event):void { var xml:XML = XML(file.data); // Your XML is here! parseXML(xml); // Do your stuff here } </code></pre> <p>As you can see, once we get a reference to the file in the file system we can read/write data from/to it freely.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload