I am new to forums so I hope I give enough info for someone to help me out. I have been having issues with the LoadVars command. It seems easy enough yet I cannot seem to get it to do what I want.
I am trying to assign a variable (count) equal to the number referenced from an external text file called Count.txt. The only text inside the file is the following:
totalFrames=3
The Flash code is the following:
var slideInfoLV:LoadVars = new LoadVars();
var count:Number = 0;
slideInfoLV.onLoad = function(success:Boolean) {
if (success) {
count = slideInfoLV.totalFrames;
trace(count);
}
}
slideInfoLV.load(“splash/Count.txt”);
trace(count);
Now here is the weird part… You will notice that there are two “traces”. The output for those is the following:
0
3
Flash reads the file and outputs the correct count from INSIDE the onload function (which outputs second for some reason) but when you trace the the variable from outside the function, it returns the initial setting of “0”.
First question, how do I get the variable count to keep the value of “3” from the external text file. Second question, why is flash outputting the values in the opposite order that I would predict, in essence, why is the second trace outputted first? I thought that flash would output from top to bottom order of code.
Sorry for the long description. Any help would be great.
Thanks!