Hi,
I’m working on a simple AIR (Building in Flash CS3) application and was wondering if some one on this forum could help me with a solution. I have like 4 text input fields that will collect user input and I’d like to save the data to a text file. Any help would be much appreciated.
Cheers
Mit
Here is an example of how to write a simple text file…
[highlight=ActionScript 3.0]import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
// Create a file.
// For this example the file will be created on the desktop.
var file:File = File.desktopDirectory.resolvePath( “my-new-file.txt” );
// Create a file stream to write stuff to the file.
var stream:FileStream = new FileStream();
// Open the file stream.
stream.open( file, FileMode.WRITE );
// Write stuff to the file.
stream.writeUTFBytes( “Hello. This is some text in a file.” );
// Close the file stream.
stream.close();
// Clean up.
file = null;
stream = null;[/highlight]
Getting the text values from TextFields should be easy enough for you.
- 06 June 2008 11:01 PM
-
Author
Yeah I’ve managed to publish air files before, based on tutorials and sample apps from adobe’s website. I know it is a bit wierd no one seems to be having this problem. I wonder if it needs to use the package { and then inside,
package {
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
public class Main {
public var file:File = File.desktopDirectory.resolvePath( "my-new-file.txt" );
public var stream:FileStream = new FileStream();
public function Main(){
stream.open( file, FileMode.WRITE );
stream.writeUTFBytes( "Hello. This is some text in a file." );
stream.close();
file = null;
stream = null;
}
}
}
The 1046 error is gone, but now i’m getting a 5000 error saying the script must subclass. Completely lost
- 09 June 2008 11:21 AM
-
Hi,
Could you please tell us how to import the flash.filesystem.* classes manually in flash cs3.
I am eagerly waiting for your reply
Chand
- 28 February 2009 10:23 AM
-
- Log in or join for free to make a comment.


