is it possible to create a plain text file with AS3 or AIR?
example: i would like to create a plain text file named "MyTextFile.txt", have it contain text that reads "This is my text file." and save it to my desktop.
another option would be to have the file already exist in a directory, so i would only have to rewrite its contents - assuming that would be easier.
all of which should happen as a background process, without any save dialoge panel appearing.
var file:File = File.desktopDirectory.resolvePath("MyTextFile.txt");
var stream:FileStream = new FileStream();
stream.open(file, FileMode.WRITE);
stream.writeUTFBytes("This is my text file.");
stream.close();
I know this is an old post, but consider the following to create a new .txt file from an input text field's text.
var tf:TextField;
var fileRef:FileReference;
function saveFile(evt):void
{
fileRef = new FileReference();
fileRef.save(tf.text, "saveFile.txt");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With