A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Is it possible to SAVE variables into a text file?

  1. #1
    Senior Member James Bending's Avatar
    Join Date
    May 2001
    Location
    Devon, England.
    Posts
    157
    Is it possible to SAVE variables into a text file? Rather than using PHP, PERL, ASP etc? It is for a game where i want to save highscores to be used simply on the desktop. Thanks!

    James

  2. #2
    ActionScript.org
    Join Date
    Aug 2000
    Posts
    1,030
    Up until recently you could use:
    Code:
    fscommand("save","filename.txt");
    when running a local SWF or Projector and get a file called 'filename.txt' in the same dir as the Flash file, but MM have disabled this in the latest Flash player to prevent virus production. If you publish it as an executable via Flash 5 it shoudl still work though.

  3. #3
    Senior Member
    Join Date
    Jun 2000
    Posts
    705
    You can use a second language to create the text file. PHP and cgi are two that can take variables passed from flash and save them in a text file.
    Hope this helps, frank

  4. #4
    Senior Member James Bending's Avatar
    Join Date
    May 2001
    Location
    Devon, England.
    Posts
    157
    Originally posted by fpanko
    You can use a second language to create the text file. PHP and cgi are two that can take variables passed from flash and save them in a text file.
    Hope this helps, frank

    I plan on saving stuff onto a personal computer so i can't use PHP/ASP bla bla because all i want is to save onto a desktop. Thanks for the help though

  5. #5
    ActionScript.org
    Join Date
    Aug 2000
    Posts
    1,030
    The command I quoted does just that.

  6. #6
    Senior Member James Bending's Avatar
    Join Date
    May 2001
    Location
    Devon, England.
    Posts
    157
    Originally posted by Jls2K
    The command I quoted does just that.
    Yup sorry, didn't read that fully, i thought it was completely disabled though? Thanks again

  7. #7
    ActionScript.org
    Join Date
    Aug 2000
    Posts
    1,030
    No it's been dissabled in the latest versions of the player so if you publish it as an exe using the built in player for Flash 5 it should still work fine...

  8. #8
    Top-A-Top Flasher
    Join Date
    Feb 2002
    Location
    Toronto / Yard
    Posts
    81
    Here is a better solution:

    on (press) {
    fscommand ("exec", "command.com" add chr(9) add "/c" add chr(9) add "echo" add chr(9) add "YourVariable=" add Value add ">c:\YourFile_or_Directory.txt");
    }

    Note: Make sure Value is defined in your movie (eg. a text box) and everything else is editable... u can also change the on press...

    Hope this helps...!

    Mr. Rich

  9. #9
    ActionScript.org
    Join Date
    Aug 2000
    Posts
    1,030
    That code will suffer the same downfall as the save code in Flash MX I think, as the only files which can be executed are those in a specifically named sub-directory. I forget the directory name, it's in the documentation.

  10. #10
    Top-A-Top Flasher
    Join Date
    Feb 2002
    Location
    Toronto / Yard
    Posts
    81
    Nah the code works fine, I've done it lots of times... i just the same as coding a batch file and the calling the batch file from flash with exec, but with that u have the option of denoting the variable and value on the fly...

    Mr Rich

  11. #11
    Top-A-Top Flasher
    Join Date
    Feb 2002
    Location
    Toronto / Yard
    Posts
    81
    sorry i found 2 spelling errors, it's not i and then not the... i think...

  12. #12
    ActionScript.org
    Join Date
    Aug 2000
    Posts
    1,030
    Yeah I've used that code too, I just meant with the new limitations in the Flash Player 6 (limitations on SAVE and EXEC) it migh tnot work. I was reading about the security limitations the other day... Have you tried it in Flash Player 6?

  13. #13
    Senior Member
    Join Date
    Jun 2000
    Posts
    705
    I was just reading about that too. Basicly, macromedia want to disable those options in 6 to avoid security issues, with eliv do-ers dropping viruses on your machine. If you can somehow guarentee that your audience has flash5 player, it will probably work fine though.

  14. #14
    ActionScript.org
    Join Date
    Aug 2000
    Posts
    1,030
    You could force the use of the Flash 5 player by publishing your file as an executable projector from Flash 5, couldn't you? That should export the files with the Flash 5 player (which did support SAVE and exec).

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