|
|||
|
//In swfkit
//Initialize d=new Date(); dm=d.getMonth(); dd=d.getDate(); dnum=dm*100+dd; exfile=File.exists("d:\\mmm.txt"); if (exfile==false){ DataFile.save("d:\\mmm.txt","dnum"); } //work if (exfile==true){ olddnum=DataFile.load("d:\\mmm.txt"); } //not work How can I load the data from the file?Please help me... |
|
|||
|
The "load" method returns a boolean value that indicates whether the variables in the data file are load successfully. It works in this way:
Your data file contains a variable named "dnum". When you call the load method, it retrieves the name of the variable, which is "dnum", and the value of the variable, which is 100*month + date, for example, today is Jan 26, it is 126. Then the "load" method create a new variable named "dnum" in ffish script and assign 126 to the variable. In your script, the "dnum" exists before the load method, it just overwrites the value of the "dnum" variable with 126. So you would have to change your code as follows. Code:
if (!File.exists("d:\\mmm.txt"))
{
var d = new Date();
var dm = d.getMonth();
var dd = d.getDate();
dnum = dm * 100 + dd;
DataFile.save("d:\\mmm.txt", "dnum");
} //work
else
{
// this method will set the value of "dnum" variable
DataFile.load("d:\\mmm.txt");
trace(dnum);
}
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|