Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-13-2008, 12:18 AM
Junior Member
 
Join Date: Oct 2004
Posts: 16
Default how to save and read Variables in a external text files ?

Hello,
Sorry for my english ... (i am french)

I want to save and read Variables in a external text files ...
I see this code in an other topic :
var f = new FileStream(getAppDir() + "output.txt", "w");
f.write("var1=" + FlashPlayer.getVariable("var1") + "&var2=" + FlashPlayer.getVariable("var2"));
f.close();

...but i don't know where i put it in flash ? or in swfkit ? ... and the file "output.exe" must be in the same folder than the exe? (i make a standalone player) .. or the "output" can be inside the .exe ?

Thanks by advance
Reply With Quote
  #2 (permalink)  
Old 04-14-2008, 05:09 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: how to save and read Variables in a external text files ?

Since it is ffish script code, you will have to put it in a script in swfkit, say "writefile". In action script you can call it by using the following code
Code:
fscommand("ffish_run", "writefile");
The txt file will be in the same folder as the exe, because you use the getAppDir() method, which returns the path name of the folder where the exe resides.
Reply With Quote
  #3 (permalink)  
Old 04-14-2008, 04:48 PM
Junior Member
 
Join Date: Oct 2004
Posts: 16
Default Re: how to save and read Variables in a external text files ?

Thanks ... many ... many ... it's works, i can write in the exe file create with swfkit ... but there's another probleme : when I re-open the .exe, the variables var1 and var2 are "blank" and i want that the var show what i write before in the output.txt.

In the first frame in flash, i put this action image code
Code:
this.loadVariables("output.txt");
and i have in the same folder the exe (create with swfkit) and the output.txt.

Thanks for your help !
Reply With Quote
  #4 (permalink)  
Old 04-15-2008, 10:37 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: how to save and read Variables in a external text files ?

In actionscript
Code:
import SWFKit.*;

this.loadVariables(global.getAppDir() + "output.txt");
Reply With Quote
  #5 (permalink)  
Old 04-17-2008, 01:18 AM
Junior Member
 
Join Date: Oct 2004
Posts: 16
Default Re: how to save and read Variables in a external text files ?

It's not work ... I can write variables but I can't read it.

I make a "test.fla" with only one image with 2 variables (var1 and var2) and a button.
On the first image I put this action :
Code:
import SWFKit.*;

this.loadVariables(global.getAppDir() + "output.txt");
on the button I put this :
Code:
on (release) {
	fscommand("ffish_run", "writefile");

	}
In swfkit I put this script :
Code:
//writefile
var f = new FileStream(getAppDir() + "output.txt", "w");
f.write("var1=" + FlashPlayer.getVariable("var1") + "&var2=" + FlashPlayer.getVariable("var2"));
f.close();
I can write on the output.txt with the .exe create with swfkit... but when I launch the .exe, the two variables are "blank " ???

Have you an idea .... and thanks for your help !
Reply With Quote
  #6 (permalink)  
Old 04-21-2008, 03:58 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: how to save and read Variables in a external text files ?

You can use the as object to loas variables from an external text file. And please use "Global.getAppDir()" method in as to get the proper path name of the text file.
Reply With Quote
  #7 (permalink)  
Old 04-21-2008, 05:46 PM
Junior Member
 
Join Date: Oct 2004
Posts: 16
Default Re: how to save and read Variables in a external text files ?

Ok ... but "this.loadVariables("output.txt");" don't work in as (the swf work but not the .exe create with swfkit) .... and "this.loadVariables(global.getAppDir() + "output.txt");" don't work too in as.

What is wrong in these codes ?
I have only one script in swfkit named "writefile" .. perhaps I must put a second script in swfkit ?

Thanks for your help ...
Reply With Quote
  #8 (permalink)  
Old 04-23-2008, 05:19 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: how to save and read Variables in a external text files ?

Please try the loadVars method in actionscript.
Reply With Quote
  #9 (permalink)  
Old 04-23-2008, 10:16 PM
Junior Member
 
Join Date: Oct 2004
Posts: 16
Default Re: how to save and read Variables in a external text files ?

Sorry for my english ... but I think you don't understand me ....
The loadVars method in actionscript works well with the swf or .exe created by flashcs3 ... but don't works in the standalone created with sfwkit : the variables are "blank" when i launch the .exe ! ??? !!!

I want to make only one file (a standalone created with swfkit for example) ... and I want the users can change some text variables in the exe and I want these changes enregistred in the .exe.

It's not possible with actionscript only ... and I want to know if it is possible with swfkit ... for example, write and load variables in a .txt file attached with the .swf ... and put the two files (.swf and .txt) in a standalone .exe created with swfkit ? Is it possible ? if it is yes ... how ?

Many many many thanks for your help and patience ...
Reply With Quote
  #10 (permalink)  
Old 04-28-2008, 02:57 AM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re: how to save and read Variables in a external text files ?

Very sorry you cannot do that, because the files packed in the output exe files are read-only. You can only write a new file in the same folder as the exe file.
Reply With Quote
Reply

Was this information helpful?    Yes No



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 05:10 AM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.