Posted By

mswallace on 06/19/07


Tagged

file actionscript types 3 Reading AIR


Versions (?)

Who likes this?

10 people have marked this snippet as a favorite

bartekk
chrisaiv
copyleft
fukami
Akuma99
THEPWN3R
dx0ne
enajenkins
tbass134
tspitzr


Reading Different File types with AS3


 / Published in: ActionScript 3
 

URL: http://office.realeyesmedia.com/blogs/john/index.php/2007/05/26/reading-a-file-with-actionscript-3/

Found this code. It is an example of loading and reading different file types with ActionScript 3

  1. import flash.filesystem.FileMode;
  2. import flash.filesystem.FileStream;
  3. import flash.filesystem.File;
  4.  
  5. var myFile:File = File.appResourceDirectory; // Create out file object and tell our File Object where to look for the file
  6. myFile = myFile.resolve("mySampleFile.txt"); // Point it to an actual file
  7.  
  8. var fileStream:FileStream = new FileStream(); // Create our file stream
  9. fileStream.open(myFile, FileMode.READ);
  10.  
  11. var fileContents:String = fileStream.readUTFBytes(fileStream.bytesAvailable); // Read the contens of the
  12. fileContents_txt.text = fileContents; // Display the contents. I've created a TextArea on the stage for display
  13.  
  14. fileStream.close(); // Clean up and close the file stream

Report this snippet  

You need to login to post a comment.