loadVars()

I have a textfile with the text “count=3” in it(without the “”).

I then have the code:

puppycount = new LoadVars();
puppycount.load(“puppycount.txt”)

inside a movieClip called “slider”, which is inside a movieclip called “puppies”. Also inside “slider” I have a dynamic textfield with variable set as “count”(without the “”).

Why won’t this work???

You have to store the value in a variable. Something like that:

puppycount = new LoadVars();
puppycount.onLoad=function(){
  count=this.count;
}
puppycount.load("puppycount.txt");

Then you’ll have a variable count holding the value 3.

pom :asian:

Thank you that works!

Do I have to convert that 3 to a number now? Because I tried this

puppycount = new LoadVars();
puppycount.load(“puppycount.txt”);
puppycount.onLoad=function(){
count=this.count;
count=Number(count);
}

and instead of the textfield showing “3” it showed “NaN”

No, it’s fine. Flash isn’t a strongly-typed language, you don’t need to bother. And if you really have a problem, well, I’m sure there’s a way out :slight_smile:

pom :cowboy: