Posted By

GrfxGuru on 01/31/11


Tagged

file actionscript text external AIR loading


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

kure69
onemanstudio
carface
elkraneo


Adobe AIR - Load local text file


 / Published in: ActionScript 3
 

  1. public var file:FileReference = new FileReference();
  2.  
  3. public function doLoad( event:Event ):void
  4. {
  5. file.addEventListener( Event.SELECT, doFileSelect );
  6. file.addEventListener( Event.COMPLETE, doFileComplete );
  7. file.browse( [new FileFilter( "Text File", "*.txt" )] );
  8. }
  9.  
  10. public function doFileSelect( event:Event ):void
  11. {
  12. file.load();
  13. }
  14.  
  15. public function doFileComplete( event:Event ):void
  16. {
  17. // txtField is the instance name of a text field used to display loaded content.
  18. txtField.text = file.data.readMultiByte( file.data.bytesAvailable, "utf-8" );
  19. }

Report this snippet  

You need to login to post a comment.