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

a) use this

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

b) remember that Flash is case sensitive. If you’re using it as all caps in the Flash file, make sure it’s all caps in the text file.

Other than that, I’m not sure what could be the problem. It looks like it should work. If you don’t find an error somewhere, maybe I’ll take a look at the files for you… I’m kind of in the middle of doing this myself, though I’m working with PHP to import a mysql database table, it’s basicaly the same thing once you get it inside Flash.

Sorry I dont think I explained my situation very well. That code works perfect.

The code I am having problems with is this

OPTIONS=_root.OPTIONS

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

This code works fine

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

Why would I use

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

if the value “done” is not numeric?

== is for numbers

eq is for strings

but I did figure out what my problem was after doing some more research

I need to use parseInt() to convert the string in my text file to numeric so I can perform mathmatical equations on it

My final code looks something like this

OPTIONS = parseInt(_root.OPTIONS)

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

Thanks for the reply though

Chris

I had just thought of that while I was reading your explination… good catch. I think that I’m having a similar problem, which I hope that your solution will solve. :slight_smile: Thanks for the info.

as a secondary note… in addition to the “eq” being taken over by “==”

The “OPT” add UPDATE in your for loop should use “+” not “add”.

Those two are just depreciated terms and may still work in Flash MX, but definitely as time goes on they will be illiminated. So eventually you’ll need to use them anyway.

btw, thanks sooooo much… I’ve been having a problem with a guestbook that I’m making, and it hasn’t worked right all week. parseInt(); was EXACTLY what I was looking for.

Interesting though… I’m using your method parseInt, and I’m getting “NAN” as a feedback on the number 5. I’m doing something wrong…

I’ll do some more reading I guess :slight_smile:

Figured it out. See action script forum…

Thanks for the command, I would not have known about parseInt(); unless you had mentioned it.

No problem…parseInt() seems to work great for me on my hard drive but as soon as I load it to a server to use on the web some of my variables return NaN…strange. You say you have solved that on the actionscript forum? What post might that solution be in?

Thanks

Chris

hmm… well now… I havent’ tried it on the server yet. I’ll be pissed if it doesn’t work there.

I’ll see what else I can discover and get back to you on it.