Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

flash var naming problems 1

Status
Not open for further replies.

ThomasJSmart

Programmer
Sep 16, 2002
634
im a having a bit of difficulty with the names of vars.

i have a txt file with some vars:
total=3&name1=tom&name2=john&name3=fred

iv loaded these into the root of my movie

i have a movieclip called holder. What i want to do is duplicate the holder MC until i have the same amount of mc's as the total var so then i have

holder1
holder2
holder3

each holder mc has a text field called name, after each duplicate movie i want to asign the _root.name var to the text field in each mc.

_root.holder1.name = _root.name1
_root.holder2.name = _root.name2
_root.holder3.name = _root.name3

this works but not the way i want it to as the contents of the text file can be any amount of names...

how do i do this? what i tried is this:


for (c=1; c <= _root.total; c++)
{
duplicateMovieClip (&quot;holder&quot;, &quot;holder&quot;+c, c+5);
set(&quot;_root.holder&quot;+c+&quot;.name = _root.name+c
}

instead of making holder1 it tried to add 1 to &quot;holder&quot; giving a result of 1,

how do i do this the right way?

any help apreciated,
thanks,
Thomas


I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
text file

&total=3&
&name0=tom&
&name1=john&
&name2=fred&

flash

mydata = new loadvars();
mydata.onload = function(){
total = myData.total;
for (i=0; i<total; i++) {
var Name = eval(&quot;myData.Name&quot;+i);
duplicateMovieClip (_root.holder, &quot;holder&quot;+ i, i);
_root.holder.name = Name;
}
}
mydata.load(&quot;textfile.txt&quot;);

//Now I havent tested this so while it may work it may well have an error. post back if it does. the text file is 100%. any mistake is in actionscript.
 
Bill, you should learn how to use the code tag on this board, when posting code. That would avoid the problem of eliminating
Code:
 codes like [i]
, that turns your text into italics rather than posting the actual code.

Please note there's also a Preview post feature, you can use before posting. You would then see your errors!

Regards,

cubalibre2.gif
 
wicked :) thanks billwatson, that did the trick,

I learned a bit yesterday, today i learned a lot, imagine what i'll learn tomorrow!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top