all groups > flash actionscript > january 2004 >
You're in the

flash actionscript

group:

LoadVars in fuction - return parameters


LoadVars in fuction - return parameters alien251
1/31/2004 9:12:11 AM
flash actionscript:
Hi all!
Once again, a newbie question, sorry.
I'll try to make it fast: I have a file called functions.as where I defined the following code:


FGloadSlideContent = function(iCourseNb, iChapterNb, iSlideNb) {
lvMyContentLoader = new LoadVars();
lvMyContentLoader.load("test.txt");
lvMyContentLoader.onLoad = function() {
MyArray = new Array();
MyArray[0] = lvMyContentLoader.var1;
MyArray[1] = lvMyContentLoader.var2;
return MyArray;

// return this;
// return lvMyContentLoader;
}
}


Where test.txt is:
var1=value1&var2=value2
Then, in the first frame of my movie, in the actions layer, I put this, in order to get the values obtained in that function and stored in the array:


arrayInfo = new Array();
arrayInfo = FGloadSlideContent(1,1,1);
trace(arrayInfo[0]); // undefined
trace(_level0.arrayInfo[0]); // undefined


I had also tried:


lvInfo = new LoadVars();
lvInfo = FGloadSlideContent(1,1,1);
trace(lvInfo.var1) // undefined
trace(_level0.lvInfo.var1); // undefined


Finally, I tried to pass the array as a parameter:

arrayInfo = new Array();
arrayInfo = FGloadSlideContent(1,1,1, arrayInfo);


Nothing works, I can't manage to get those values. When I did the .load in the main movie, it works.
If someone could help me it would be very nice!
Thanks a lot!
Tiago

Re: LoadVars in fuction - return parameters kglad
1/31/2004 3:32:33 PM
that code is problematic. every time you execute a function call there's some amount of time required to load your text file and you're using (or trying to use) a return function value before your text file is loaded. that can't work. however, with some delay you can start using MyArray, after a function call.

AddThis Social Bookmark Button