|
|||
|
I am very interested in buying swfkit. However, I have been reviewing the trial version and I have had trouble getting the readfromfile function to work. I want to be able to read a text file that just contains several lines of text. I can't seem to get it to work. Could you please send me a sample?
Thanks |
|
|||
|
Code:
var f = new FileStream('c:\\test.txt');
if (f != null)
{
while (f.pos < f.length)
{
trace(f.readLine());
}
}
Code:
var f = new FileStream('c:\\test.txt');
if (f != null)
{
trace(f.readString());
}
|
|
|||
|
Thanks for the code. However, I wanted to try to save the data from the file to a variable in Flash. Here is the code I tried but it did not work. Thanks for the assistance.
var f = new FileStream('c:\\test.txt'); var g = ""; if (f != null) { trace(f.readString()); g = f.readString(); } FlashPlayer.setVariable("_level0.str_loc", g.toString()); |
|
|||
|
Please don't call the "readString()" method twice. The first call will return the proper result. But the file pointer seeks to the end of the text file after the first call returns. Then the second call returns a empty string.
Please do like this Code:
var f = new FileStream('c:\\test.txt');
var g = "";
if (f != null)
{
g = f.readString();
trace(g);
}
FlashPlayer.setVariable("_level0.str_loc", g.toString());
Code:
var f = new FileStream('c:\\test.txt');
var g = "";
if (f != null)
{
trace(f.readString());
f.pos = 0;
g = f.readString();
}
FlashPlayer.setVariable("_level0.str_loc", g.toString());
|
![]() |
Was this information helpful? Yes No
| Thread Tools | |
| Display Modes | |
|
|