Loading Vars Duplicating MCs and the like

Ok heres the deal…

Im loading variables from a text file into my main timeline. There are many variables in the text file but the key one i am having trouble with is OPTIONS=6.

I later call that variable from the main timeline from a MC nested far within my movie by using

OPTIONS=_root.OPTIONS

then i use a for loop to duplicate a MC 5 more times

for (UPDATE=1; UPDATE<OPTIONS; UPDATE++) {
duplicateMovieClip(“OPT0”, “OPT” add UPDATE, UPDATE);
}

well this dosent work…sigh

but the funny thing is…

if i manually specify OPTIONS=6 on my main timeline the whole thing works

i have already made a loop that checks to see if my textfile is loaded by adding loaded=done at the bottom of my textfile and in my main timeline i use

if (loaded eq “done”) {
gotoAndStop(5);
} else {
gotoAndPlay(2);
}

to stop my movie from playing until all variables are loaded

also…i know its not a problem with my code that loads my text file cause i call many other variables from that file and they all work in the rest of my movie

ok all you flash gods im praying you will have the answer

Thanks in advance

Chris

all variables loaded from a text file are by default strings.
try this code to fix the problem:
for (UPDATE=1; UPDATE<(OPTIONS*1); UPDATE++) {
duplicateMovieClip(“OPT0”, “OPT” add UPDATE, UPDATE);
}

or this

for (UPDATE=1; UPDATE<Number(OPTIONS); UPDATE++) {
duplicateMovieClip(“OPT0”, “OPT” add UPDATE, UPDATE);
}

that might do it…there might be something else going on so trace the variables after you load them just to make sure they’re there.
:slight_smile:
jeremy

Well, sadly neither of your suggestions worked. But on the bright side I did get it to work. When you mentioned that vars in a text file are strings I did some more research on that. I found that parseInt() in the function that I needed to use. parseInt() converts strings to numbers…similar to the Javascript eval() function.

my code now looks something like this

OPTIONS = parseInt(_root.OPTIONS)

for (UPDATE=1; UPDATE<OPTIONS; UPDATE++) {
duplicateMovieClip(“OPT0”, “OPT” add UPDATE, UPDATE);
}

thanks for all your help!

Chris