Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Saving and Loading variables in a .txt file (Offline)

New Here ,
Jan 22, 2008 Jan 22, 2008
I'm working a software we've done with Flash, but we'd want people to be able to save the variables they selected. We need them to be able to save the value of about 10 variables in a file on their desktop, and then be able to load that file again.

Is it possible to do that without having to use php or stuff like that (that's why we want to make it an offline applications so we don't have to use php to be able to save files).

I know Actionscript looks a lot like Javascript and with Javascript it's really easy to do, but all the saving functions are blocked in Flash for security reasons.

If anyone knows how to do that, to simply save and load a .txt file, please let me know. If it would be possible also to change the .txt to whatever else it would be even better. The file can still be opened in Notepad but at least it looks a bit more professionnal to have our own extension. Again in Javascript or with a .bat file it's really easy to save variables to whatever type of file, even to non existing types, it simply creates a text file with an unknown ending.

Thanks!
TOPICS
ActionScript
1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 22, 2008 Jan 22, 2008
Look up "shared objects" - It is very handy in storing data locally.

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/SharedObject.html

** be sure to read the user comments at the bottom
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 22, 2008 Jan 22, 2008
If you are running an offline flash projector movie, you can use fscommand to launch a separate exe, and then use that to save whatever you want.

You can use the clipboard to pass arguments to the exe: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid=1303758&h...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 22, 2008 Jan 22, 2008
If I understand well your problem, you have a Flash application that has to save some date on the local machine so that another program can open that file for viewing.

I don't know if you are using AS2 or AS3. The trouble with SharedObject is that is not really visible and it is meant to be used instead of a cookie.

So, here is my idea:

Use ExternalInterface to communicate with a JavaScript function that can save the variables into the local file. The cool thing about the ExternalInterface is that its a clean solution and you can pass values without any problem. How ever, this is not the fastest implementation for your need.

I hope this helped.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 23, 2008 Jan 23, 2008
Thanks to the four of you who answered.

I'm using Flash CS3.

I think I'll go with Ramindeja's solution since I already know Javascript good enough to be able to save and load files in any kind of format and since I need the file the be viewable to the user because the properties in the files will need to be shared between people, so they will need to be easily sendable by email. With javascript there's no problem with that. Now I just need to wait for my Flash guy to have some free time to try it out because sadly my company still haven't gotten me Flash on my computer so I can't test it myself for now.

I'll let you know when there are some updates on my side.

Thank you.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 24, 2008 Jan 24, 2008
I found a page that explains in a really easy way how to communicate with Javascript if the flash object is contained in an html page, but I couldn't find any page explaining how it works if it's not in an html page. On our side, before using the software we're creating we'll convert it to a .exe. How can we call a Javascript from that .exe since we can't incorporate the Javascript in the container since there isn't really a container... Is there a way to link to a Javascript (.js) that would be in the same folder as the .exe? Or would there be a way to incorporate the Javascript right into the .exe?

Let me know if any of you have a solution for that.

Thanks!

http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Part...
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 24, 2008 Jan 24, 2008
LATEST
In that case, may be you should consider the solution posted by dr_ross.

There is also mprojector that converts your SWF to an EXE. mProjector and Zinc have APIs that can communicate with the OS (file creation, registry read/write, etc). There is also Adobe's AIR.

Frankly, there is no need to use JS anymore, since you're going to create a desktop application.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 23, 2008 Jan 23, 2008
If you want to save out text files from an offline projector the easiest way is to wrap your exe in a third party product.

There are three main ones availiable

FlashJester - http://www.flashjester.com
Northcode - http://www.northcode.com/
and Zinc from mdm - http://www.multidmedia.com/

all have saving text file as their most basic tutorial.

Hope that helped, Dr.Ross
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines