Actually, although I found my solution in SharedObjects, I did find an
example online that will let you write to a text file straight through
Flash.  It uses the following line to write the file:

fscommand("writeToDisk", textBox);

It says it only works on Windows, so I'm assuming the "writetodisk"
command is something that only is supposed in the windows version of
flash.  Just thought I'd share.

John

-----Original Message-----
From: Darron J. Schall [mailto:[EMAIL PROTECTED]
Sent: Friday, April 02, 2004 4:05 PM
To: CF-Talk
Subject: Re: desktop application

> No, I understand how to get from XML to the DB, but if the Flash file
> is running directly on a client machine (CF not installed and no
> internet
> connection) how do I get Flash to write the input to a text or xml
> file for upload later?

You can't get Flash to save a .txt file on the client on it's own.  To
do that, you'll need a 3rd party projector creator (Something SWF
Studio, Flash Jester, or ScreenWeaver).  ScreenWeaver is my
projector-creator of choice.

Then, each projector creator offers an ActionScript API to enable some
"advanced" features like writing to a text file.  In ScreenWeaver, you
could do something like this:

var fileName = "something.txt"
var contents = "Hey, this is what should be placed in the file"; var
bAppend = false; // don't append if the file already exists

function onFileSave(success) {
    if (success) {
        // file saved ok
    } else {
        // file could not be saved
    }
}

swFile.saveString(fileName, contents, bAppend, onFileSave);

The other option, if you don't want to go the 3rd party route, is to
uses Shared Objects in Flash (requires Flash MX).  You can do this
natively in Flash, but it won't create a text file.. it creates a binary
file that you can read in later.

Shared Objects look like this:

myData = SharedObject.getLocal("someData");
if (myData.data.content.length) {
    // content stored.. we can retrieve the value by referencing:
myData.data.content
}

// set some data
myData.data.content = "This is some text to save for later";
myData.flush();  // write the contents immediately

Good luck..

-d
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to