PDA

View Full Version : writing text to a text file


active
04-13-2001, 06:12 AM
Is it possible for a user to input text (into an input text box) and have Flash write that text to a local text file that can then be accessed by Flash.
EG. user inputs several words. The words are saved onto a text file. The words are then accessed and displayed as dynamic text.
I have no problems retrieving the words dynamically, but I cannot find anywhere how to have the user provide the words.
Somebody's help on this would be appreciated.

Jesse
04-13-2001, 06:18 AM
Only if the Flash file is a local presentation. You can't save files to the HDD if the user is viewing through their browser (online or offline).

Assuming you're using the standalone player or the Flash Projector you can use this code:

fscommand("save","file.txt")

That will save all variables currently in the Flash file into a text file (file.txt) in the correct format for Flash to read them back in later.

I've heard this doesn't work on Macs.

Cheers

Jesse

active
04-13-2001, 06:30 AM
thank you for your quick reply.
I think I understand what you are saying about saving the text onto the HDD.
So... if the txt file is residing on the same server that is hosting the html document and the swf, is it possible for the users input to be written there and if so what would be the way of going about it?
Cheers

Jesse
04-13-2001, 07:27 AM
Both can be done.
1. To save to the local hard drive, you must be runing a local presentation (via the Standalone player or Projector)
2. To save to the server which hosts the SWF file you must use a browser and a server-side script.

Which are you doing? Online or local?

Cheers

Jesse

active
04-13-2001, 07:35 AM
I need to be able to save to the server, so I need to know how to have it write online.

Thanks

Jesse
04-13-2001, 09:10 AM
This will require a server-side scripting language then. My language of preference is PHP. Find out if your server supports PHP, then see this thread:

http://www.actionscripts.org/forums/showthread.php3?threadid=851

Or this thread:
http://www.actionscripts.org/forums/showthread.php3?threadid=749 (FlashGuru also gives a CGUI based example here I think)

If you still need more help, reply here.

Cheers

Jesse

active
04-14-2001, 12:30 AM
Thank you Jesse. I will puzzle over the PHP scripts today if I get time. Can you direct me to any dialogue on how to do this if working it for the alternative, ie on a local hard drive as a stand alone projector.
I think that I need to look at all alternatives before I commit any more time to this project.
Happy Easter by the way.
Cheers

Jesse
04-14-2001, 02:49 AM
Happy Easter to you too :)

Like I mentioned above, the way to go baout it with the Projector is to use this fscommand:

fscommand("save","file.txt")

It's realyl just as simple as that (PC only)

Cheers

Jesse

elmo
04-24-2001, 10:49 AM
Hi, I'm running a standalone flash movie locally but it is on a CD-ROM.
I would like the user to be able to specify the folder so they can save the txt file to a floppy or into a folder on their hard drive since CD-ROM is read-only.
Is there a way to do this?
Help me... please...

Jesse
04-24-2001, 11:59 AM
There is no browse function in Flash so the user would have to type in the path themselves...

This sample code works fine:

variable = "1235";
path = "c:\\file.txt";
fscommand ("save", path);

Cheers

Jesse

elmo
04-24-2001, 10:10 PM
Hi Jesse,

I tried the sample code you gave me and it works fine, but when I open the saved txt file I see this:

&variable=1235&path=a:\file.txt

Hmm... is there anyway we can make it to ignore all those other information and record just the stuffs we need - i.e., variable name and its value (1235)?

Wow I am such a newbie... thanks!

elmo
04-25-2001, 12:03 AM
Ok this is my actual code:


on (release)
{
"\n\n" + TextField1 + "\n\n";
fscommand ("save", "a:\\file.txt");
}


// "TextField1" is the variable name for my input text box. I was hoping that "\n\n" will insert lines between useless other crap. It didn't work. Actual output on txt file reads as follows:


&TextField1=Blah Blah Blah...&constructor=[type Function]&__proto__=[object Object]


// "Blah Blah Blah..." is the text I entered. No evidence of "\n\n" whatsoever...

What am I doing wrong here?

Jesse
04-25-2001, 02:22 AM
Save will save all variables in the Flahs movie, the only way to stop that is to delete variables with the delete command.

Cheers

Jesse

elmo
04-25-2001, 02:27 AM
umm like, ok and stuff?

uhh so like how do i do that and stuff??

Jesse
04-25-2001, 09:16 AM
Save is the only way I've ever used to do this. You can (I hear) on PC systems use and exec on command.com and write text files that way but I've never done it and I can't find any posts on it no matter how I look.

These is software you can get (about $100USD) which specializes in doing this also...

Save is actually an 'undocumented feature', really just made for exporting variables if you want to save settings for a projector file which you might chose to load again, not really made ofr exporting content like readme files and stuff.

Cheers

Jesse

elmo
04-25-2001, 09:54 AM
hmm... so that's it hah? this sucks.

Marx
04-25-2001, 12:34 PM
Hi...
Jesse mentions the 'command' version of writing txt files to your hard drive, thought you'd like to see it:

on (release) {
fscommand ("exec", "command.com\t/c\techo\ttxtInput\t>>writeFile.txt");
}

Good luck.

Jesse
04-25-2001, 12:40 PM
(Thanks for bailing me out Marx, I had totally forgotten it.)

Cheers

Jesse

elmo
04-26-2001, 06:12 PM
hmm...

I tried that exec thing and all I get is "Invalid Switch" error.

what am I doing wrong now???

allarr
01-05-2002, 06:54 PM
this thread has been a lot of help thanks,
but..
variable = "1235";
path = "c:\\file.txt";
fscommand ("save", path);

I've had two problems...I can't seem to set the path to the desk top

secondly..If I have a user input variable
say fileName = "some user text input"

How can I get the file.txt to be written as fileName.

so far nothing has worked

thanks al