|
|||
|
Hi
I've been working with swfkit for a week and can't work out the simplest functions. Have read all the helpfiles etc but just don't understand. Can someone help me by outlining the process for save and load to text file? What I'm trying to do is: On app load, open a text file with one value in it (a number). If file not exist, create text file and set default content to a number (0). I basically just need to read the value in this text file every time the app is opened and if nescessary re-write with a new value. I'm pretty sure this is a very simple action in swfkit but no matter how many times i read the helpfile or search this forum, I don't understand it. plz help this struggling n00b ;D |
|
|||
|
1) in the "initialize" script of swfkit, check whether the file exists
Code:
var filename = getAppDir() + "myname.txt";
if (!File.exists(filename))
{
// create the file and write 0
var filestream = new FileStream(filename, "w");
filestream.write('0');
filestream.close();
}
3) in action script call the fscommand to re-write the txt file. E.g, in "initialize" script you can write a function to re-write the txt file and then call the function in action script in ffish script Code:
function saveString(name, data)
{
var filename = getAppDir() + name;
var filestream = new FileStream(filename, "w");
filestream.write(data);
filestream.close();
}
Code:
myfilename = "test.txt";
mydatastring = "value=hello";
fscommand("ffish_eval", "saveString('" + myfilename + "','" + mydatastring + "')");
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|