Hi,
I want to load a simple variable (like a number) from an external text
(txt) file.
This is the code I have:
loadVars("numimg.txt", "")
numimg = var_txt;
It seems a little too simple to work, and of course, it doesn't. It says my
computer will go very slow if I continue to run it and then it closes. I think
it might be because the file isn't loaded when I try to get the variable. So
then I tried this:
var loadnumimg = loadVars();
if (loadnumimg.percentLoaded = 100) {
numimg = var_txt;
}
loadnumimg.load("numimg.txt")
But, seeing as how I am writing this post, you can safely assume that it
didn't work. :sad;
Can anyone help me?
Thanks, Hengy
PinoStyL - 10 Nov 2006 15:33 GMT
Your text file needs to include a reference variable in it.
Suppose a single line text file should read:
number=1234567890
You close that and save it as "numimg.txt"
On your stage, create a dynamic text field and call it var_txt (per your
example)
Now the ActionScript:
var loadNumimg_lv = new LoadVars(); // the _lv suffix will help with Flash
giving you hints
loadNumimg_lv.onLoad = function() {
var_txt.text = loadNumimg_lv.number; // the suffix ".number" refers
to the reference variable inside the text file.
}
loadNumimg_lv.load("numimg.txt"); // if it's in the same folder as your swf
loadNumimg_lv.load("text/numimg.txt"); // if it's in a sub folder called
"text"