PDA

View Full Version : Is this possible w/ LoadVars and onLoad?



waterman
August 5th, 2003, 01:41 PM
Greetings! This is my first post, but I've been snooping around here for a little while. Thanks, Kirupa, for such a great resource!

Here's the situation:

I've got a URL-encoded text file that looks like this:

sw1=on&sw2=off&sw3=on (etc, etc.)

On the stage I have instances of movie clips named sw1, sw2, sw3, etc. Those movie clips have two frames each that are labeled "on" and "off."

I want to load the text file in and have the movie clips go the appropriate frame based on the variable's property. I can trace both 'i' and 'this[i]' ('i' is a variable in the code below), so I know the variables and properties are there, but I can't control the movie clips using the line:

i.gotoAndStop(this[i]);

Is this possible? Is there a way to accomplish this same goal? I'm new to AS, but I've had some experience with other languages. Be gentle. Here's the code segment for my onLoad function...


myLoadVar = new LoadVars();
myLoadVar.onLoad = function() {
for (i in this) {
if (i != "onLoad") {
trace("The variable " + i + " is set to " + this[i]);
i.gotoAndStop(this[i]);
}
}
}


Thanks for your input. I really appreciate it.

kode
August 5th, 2003, 04:14 PM
eval(i).gotoAndStop(this[i]);
Should do...

waterman
August 5th, 2003, 04:53 PM
Awesome, kax. Worked perfectly.

I think that'll be one tip to hold on to. :)

Thanks for your help.

kode
August 5th, 2003, 05:32 PM
No problem. ;)

Also check this link: http://www.kirupaforum.com/forums/showthread.php?s=&threadid=12082