dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Problem writing from Flash 5 to txt file - HELP ASAP PLS

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    6

    I'm developing a form that should allow the user to change the details of already existing txt files from flash. I've no problem loading the variables from the text files to the Flash form fields with dynamic text. However, if I want to change any of the variable contents and write them back to the text files, I just don't find any way of doing it without passing by ASP, which I can't do, as the appl is to be run offline.
    I'm trying to get to grips with fscommand, exec and dos commands but honestly I haven't got a clue of what I'm doing. The fscommand line should go after

    on release {
    fscommand("exec", ................)

    after which anything I try doesn't affect the text at all.


    Has anybody got any suggestions pls?

    Thanks a lot.

    Ap


  2. #2
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766

    SWF Studio (www.northcode.com) is a tool that will convert your SWF files to EXE files with some extra functionality. It also comes with some FREE plugins that can help solve your file I/O problems.

    The FILESYS plugin (www.northcode.com/studio/plugins/filesys.html) allows you to easily read and write text files using the FILESYS.READFILE and FILESYS.WRITEFILE commands.

    The INIFILE plugin (www.northcode.com/studio/plugins/inifile.html) gives you a way to read and write INI files. Adding some structure to your files makes data retrieval much easier.

    Check out the SWF Studio support forums at http://www.northcode.com/forums and if you get stuck you can also find me here or at support@northcode.com


  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    666
    First of all a 3rd party tool is not required to write .txt files you can used the unsupported Save command..

    Here's the best URL I found on the web concerning how to use it..
    http://groups.google.com/groups?q=Fs...iveyleague.com

    You can also use the command line method.. there was a excellent reference of a how to in a thread on flashkit I recommend you try several search's.. (it's there it may just be a bit buried)

    Lastly you can use 3rd party programs (like mine), Northcode's or ***********'s

  4. #4
    *********** JTools - JSave

    http://jtools.***********.com


    Good luck

  5. #5
    Junior Member
    Join Date
    Oct 2001
    Posts
    6
    thanks, I'd rather use no third party tools, as it's for my final... I've tried

    fs ("save", "file.txt")
    and it works, but as u said there's all the variables in the flashfile, whereas I require just some specific ones (form fields).

    I've tried the following command lines:

    1.
    on (release) {
    fscommand ("exec", "command.com" add chr(9) add "/c" add chr(9) add "echo" add chr(9) add question add ">c:\\writeFile.txt");
    }

    2.

    on (release) {
    fscommand ("exec, "command.com" add chr(9) add "/c" chr(9) add "echo" add chr(9) add question add ">>writeFile.txt");
    }

    but I get a (syntax) error message on playing/publishing and nothing more.

    Any other suggestions ?

    TA

  6. #6
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766

    Check out http://www.ci-berpages.com/flash/flash.htm for info on how to write data to a text file from Flash. You'll find working examples of how to do it with just Flash. But you should know that there are caveats with using the command.com approach too.

    Les also has some new freeware tools that allow you to do this. If you don't want to use a third party tool (free or not), you're going to do a lot more work than you have to.


  7. #7
    Junior Member
    Join Date
    Oct 2001
    Posts
    6
    Thanx, I've tried the w/s and it works to a certain point. the problem that still remains is -- I can I write a string with separators to a txt file?

    If I go back to coding, this is what I've done:

    on (release) {
    textVar = "question=" add question add "&a1=" add a1 add "&a2=" add a2 add "&a3=" add a3 add "&ca=" add ca add "&category=" add category add "&level=" add level;
    gotoAndPlay ("edit2");

    txtVar2 = "";
    len = textVar.length;
    for (x=0; x<len; x++) {
    space = textVar.substring(x, x+1);
    if (space == chr(32)) {
    txtVar2 = txtVar2 add "|";
    } else {
    txtVar2 = txtVar2 add space;
    }
    }
    trace (txtVar2);

    fscommand ("exec", "command.com" add chr(9) add "/c" add chr(9) add "echo" add chr(9) add txtVar2 add ">C:\\writeFile.txt");
    }

    The "|" char is added at the end of each word and appears in the swf file, but when it comes to writing the string to the txt file, its content is actually erased. Unless the string has no spaces in between and doesn't need parsing.

    Please help, I'm really going round the bend with this.

    Thanks
    Apt966


  8. #8
    Tim (Super Moderator) Northcode's Avatar
    Join Date
    Dec 2000
    Location
    Whitehorse YT
    Posts
    3,766

    The "|" has a special meaning to the DOS command line. It's called a "pipe" and it's used for sending the output of a process to another process. You can't use it.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center