Return to Snippet

Revision: 3213
at June 19, 2007 05:28 by mswallace

Initial Code
import flash.filesystem.FileMode;
      import flash.filesystem.FileStream;
      import flash.filesystem.File;
      var myFile:File = File.appResourceDirectory; // Create out file object and tell our File Object where to look for the file
      myFile = myFile.resolve("mySampleFile.txt"); // Point it to an actual file
      var fileStream:FileStream = new FileStream(); // Create our file stream, FileMode.READ);
      var fileContents:String = fileStream.readUTFBytes(fileStream.bytesAvailable); // Read the contens of the 
      fileContents_txt.text = fileContents; // Display the contents. I've created a TextArea on the stage for display
      fileStream.close(); // Clean up and close the file stream

Initial URL

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

Initial Title
Reading Different File types with AS3

Initial Tags
file, actionscript, 3

Initial Language
ActionScript 3