Post Text Box Text Into Text File


/ Published in: ActionScript 3
Save to your folder(s)

This code shows how not only to create a text file onto the local computer desktop, but also how to post the contents of a 'text box' object into the file.


Copy this code and paste it in your HTML
  1. //Sin Verguenza Games - Google Play Store
  2. import flash.filesystem.File;
  3. import flash.filesystem.FileMode;
  4. import flash.filesystem.FileStream;
  5. //store the text box text into a variable that will be used later in the code
  6. var printerData = printer.text.toString();
  7. var file: File = File.desktopDirectory.resolvePath("score.txt");
  8. var stream: FileStream = new FileStream();
  9. stream.open(file, FileMode.WRITE);
  10. //this line below actually posts the text box text into the created file
  11. stream.writeUTFBytes (printerData);
  12. stream.close();
  13. //Orlando Florida USA

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.