Posted By

allnatural on 01/22/10


Tagged

AIR FileStream


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

mediapoint
thastyle


Adobe AIR FileStream Example


 / Published in: ActionScript 3
 

URL: http://www.destroyyourcomputer.com

  1. <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
  2. layout="absolute"
  3. creationComplete="init();">
  4. <mx:Script>
  5. <![CDATA[
  6.  
  7. private var file : File;
  8. private var fileStream : FileStream;
  9. private var fileContents : String;
  10. private const ISO_CS : String = "iso-8859-1";
  11.  
  12. private function init() : void
  13. {
  14. file = new File();
  15. file = File.applicationDirectory.resolvePath("file.txt");
  16. fileStream = new FileStream();
  17. fileStream.addEventListener( Event.COMPLETE, fileComplete );
  18. fileStream.openAsync( file, FileMode.READ );
  19. }
  20. private function fileComplete( event : Event ):void
  21. {
  22. fileContents = fileStream.readMultiByte( fileStream.bytesAvailable, ISO_CS );
  23. trace( "fileContents="+fileContents );
  24. }
  25. ]]>
  26. </mx:Script>
  27. </mx:WindowedApplication>

Report this snippet  

You need to login to post a comment.