Is there any reason why this shouldn’t work?? I know the variables are loading because I can call them without using arrays, also if I just put a sting such as “hello” in myArray[0], I can trace it. Otherwise I keep getting undefined. Any help is much appreciated, this is driving me crazy! Thanks.
test1="some value";
myArray = new Array();
myArray[0] = test1;
trace(myArray[0]);
The problem might be that you don’t wait for your variables to load. your variables like test1 are undefinded in the first place and the script gets executed before they have time to load.
See using LoadVars with onData event handler.
I’m loading the txt file in the Main swf, but I’m not actually calling them until I load an external swf, so I know they have had time to load. And I’ve called the variable without the array in the same place and it loads fine. I know this all seems correct, but for some reason I can’t get it to work. I’ve tried loading the .txt file both of these ways:
if you say that you can trace fine the variable… it means it loaded succesfully :)… this is proof enough.
Let’s see… An array[1] for instance is not a real variable… It’s a pointer. Your problem probably involves this.
you say that you can’t trace the value of array[1] wich was supposed to be the content of test1 variable.
try this. After you load your vars
But yes, I was indeed loading it into _level 0 on the _root timeline.
You will by no means ever insult me by trying to help me. I am by no means an expert in Flash, so most of my mistakes are little obvious things. I do appreciate your help on this issue so far. I am in the process of trying out your suggestion in your previous post. Thanks again.
loadVariablesNum("whatever.txt", 0)
//say we have variables in the text file called test1, test2, test3.//
myArray = new Array();
myArray[0] = loadVariablesNum.test1;
myArray[1] = loadVariablesNum.test2;
myArray[2] = loadVariablesNum.test3;
trace(myArray[0])
on Button:
on (release) {
trace(myArray[0]);
} result = undefined
I guess I thought that as long as I was trying to call the array from somewhere else with a button after I knew the text file was loaded everything was ok, but the file was never getting loaded before I was trying to set the variables to the Arrays. So by putting this:
loadVariablesNum(“whatever.txt”, 0)
on Button:
on (release) {
myArray = new Array();
myArray[0] = test1
myArray[1] = test2
myArray[2] = test3
trace(myArray[0]);
That seemed to work just fine. Thanks for the help guys.