/ Published in: ActionScript 3

Read a file from the FileSystem
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private var file : File; private var fileStream : FileStream; private var fileContents : String; private const ISO_CS : String = "iso-8859-1"; private function init() : void { file = new File(); file = File.applicationDirectory.resolvePath("file.txt"); fileStream = new FileStream(); fileStream.addEventListener( Event.COMPLETE, fileComplete ); fileStream.openAsync( file, FileMode.READ ); } private function fileComplete( event : Event ):void { fileContents = fileStream.readMultiByte( fileStream.bytesAvailable, ISO_CS ); trace( "fileContents="+fileContents ); }
URL: http://www.destroyyourcomputer.com
Comments
