how can i add a content of a variable into a .txt file?
simple question needs a simple answer.
Cheers!
/ZeusVL
load the variables using the loadVariablesNum() method. If you specify 0 then the variables will load to _level0 which equates to _root if your movie only contains one level
Declare you variables as you would in Flash and separate variables with ampersands (don’t add any additional spaces) e.g.
dog=25&oatmeal=“farinacious”
Don’t forget that if you’ve a slow server then there can be a delay between client request and server response and if your server hangs in the middle of serving a long txt file then your vars may be incomplete
It’s good practice to include a “junk” variable at the end of your txt file so that you know all the vars have been loaded and declared
e.g.
dog=25&oatmeal=“farinacious”&alldone=true
then if you call the txt file using
alldone=false
loadVariablesNum (“vars.txt”, 0);
you can perodically test for alldone and handle any errors that arise
hmm, Im sorry but i didnt quite understand.
Create text file called vars.txt containing the text
dog=25&oatmeal=“farinacious”
with no additional spaces, carriage returns or line breaks. (Assuming that you want to declare two variable one a numerical variable called dog with a value of 25 and the other a string variable called oatmeal with a value “farinacious” - obviously you’ll need to edit this to suit your purposes)
Then it the place where you want to declare your variables i.e. the place where you would otherwise type
var _root.dog=25
var _root.oatmeal=“farinaceous”
instead type
loadVariablesNum(“vars.txt”,0)
and make sure that vars.txt and your swf are in the same folder
hmm, could you show me an example?
here we go:
Try looking at the enclosed zip loadVarsExample.zip
Have a look at
thats not the first time that happens
I think he’s asking how to save text file from Flash… FSCommand save still work in Flash 5???
yeah after i saw your example I think u have understood me.
fscommand (“save”, “bla.txt”)
u mean?
Yes… That’s what I have meant, but I am not sure if that still works or not… I know that it should work if your user have FP5 installed, but it’s kinda outdated now, so I am afraid that wouldn’t do any good for you…
Are you trying to save a text file for the projector or the web based one??? And you DO use F5 for this project, right???
Ok.
Yes I use F5 for this. Well it´s just a experiment, but I think i will use it on a webbased one.
Well… I guess it’s your job to search the web to see if fscommand save still works or not…
If you have a project for the web which needs to save a text file, then you gotta get the server side script to do the job… No other way I know of rather than that…
If you want to save to a txt file in Flash 5 then you’ll need a server side script (VB, php, etc) and sufficient server permissions to set the chkmod of your txt file (777 = read/write/execute).
You pass your variables to the server script using the getUrl() method specifiying GET/POST as appropriate.
Alternatively, if you only want to use Flash, then MX has the ability to store persistent local data.