I found a tutorial that explained how to load an external text file into a text field and that worked fine. The issue I’m having is when I try to load the text file into a variable that isn’t a text field object.
The code from the tutorial was:
textLoader = new LoadVars();
textLoader.onLoad = function()
{
textFieldInstance.text=this.content;
};
textLoader.load("text.txt");
The problem I’m having is if after the .load line I have “trace(textFieldInstance.text)”, the output is blank (presumably its initial value). I’ve tried using some other variable in place of “textFieldInstance.text” and I have the same problem. If I do the trace inside the onLoad function, it displays the correct value, but if it’s outside the function it just returns the variable’s initial value. I’m assuming it’s a scope problem, but I’m not sure how to resolve it. Any help would be appreciated.
Thanks,
Deepak