Language: ChineseGermanSpanishFrenchDutchItalianRussian
123 Flash Chat Forums

Go Back   TOPCMM Community > SWFKit > SWFKit Support

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-03-2006, 03:49 PM
Junior Member
 
Join Date: Jul 2006
Posts: 3
Default Simple save and load text file

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
Reply With Quote
  #2 (permalink)  
Old 07-06-2006, 01:36 PM
Senior Member
 
Join Date: Dec 2002
Posts: 2,015
Default Re:Simple save and load text file

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();
}
2) in action script use the "loadVar" method to read the txt file

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();
}
in action script call the function
Code:
myfilename = "test.txt";
mydatastring = "value=hello";
fscommand("ffish_eval", "saveString('" + myfilename + "','" + mydatastring + "')");
If you still have problems, please send us a sample. We will show you how to make it work.
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 03:44 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.