tags:

views:

66

answers:

4

Hi, I am new to Adobe Flex. I want to write some data stored in a string variable into a text(txt) file. Can some one add sample code here would be helpful for me. Thanks.

A: 

You cannot write to files in Flash, but you can if it's an AIR app. Review the File class in Adobe livedocs.

Robusto
Thanks Robusto. Can you add that sample code in AIR
sanjeev
Flash 10 has api, where you can read and write files to local disk provided the open file dialog is called only on click of a mouse.
Akash Kava
Indeed it's wrong saying Flash can't save files. If you're targetting Flash 10, FileReference.save() will work as long as it's called after a user interaction
PeZ
Perhaps I phrased it poorly. What I meant was you couldn't just save files without user intervention and consent. The 'FileReference' class (which the File class extends) does not allow your app to save any old file you (the developer) choose. From the phrasing of the question, that is what it seemed to me the OP wanted to do.
Robusto
A: 

If you're creating web based apps, the file will have to be created on the server, and you should look for information in that using the technology of your choice. ColdFusion uses the cffile tag, as one example.

FileReference.save will give your user the ability to save a file, but you have limited control in naming or location.

If you're using AIR, you can save information to the local drive using the File class.

www.Flextras.com
+1  A: 

You can write to files if you're targetting Flash 10. Read this article to find out how to do it: http://www.mikechambers.com/blog/2008/08/20/reading-and-writing-local-files-in-flash-player-10/

Robert Bak
A: 

Since Flash Player 10 you can use the FileReference.save() method.

splash