Hello everyone…
First time poster and beginner Actionscripter. The solution to the described problem probably is something incredibly simple…I just can’t figure it out.
Below is some code that simply uses loadvars to get data from an external text file. It resides in layer1, Frame1 (nothing else exists in this test FLA):[indent]var myLV:LoadVars = new LoadVars();
var tempstr:String = “not working!”;
function assignString() {
myLV.onLoad = function (success) {
if (success) {
tempstr = myLV.info;
trace(tempstr);
}
}
}
myLV.load(“test.txt”);
assignString();
trace(tempstr);
[/indent]Test.txt contains the following:
info=I hope this works
When I test the movie, I get the following in the Output box:
not working!
I hope this works
I expect I would see “I hope this works” on both lines; instead, the root variable was never assigned the loaded info. I’m assuming this is a problem with the scope of my variables and how they are declared.
I would like to pass the myLV.info string to other functions (i.e. make it available globally). Ultimately, I would like to load text using LoadVars, convert to a number and assign the number to a counter to be used in other functions.
Any help you can provide will be greatly appreciated.
Thanks!
rxteach