Put a mc into a variable

I used the duplicate movie clip to duplicate a m.c-but later on I want to refer to it in a variable-so how can I put the value of the copied m.c into the variable?
here’s my code:

duplicateMovieClip(“Tline”,“TLine”+number,2);
avail=“TLine”+number;
number++;

when I trace avail now I get Tline5 (for ex.)-but it doesn’t reflect the real line that got duplicated
thank you

There are a few options:

var avail = TLine.duplicateMovieClip("TLine"+n, n++);
// eval
TLine.duplicateMovieClip("TLine"+n, n);
var avail = eval("TLine"+n++);
// associative array referencing
TLine.duplicateMovieClip("TLine"+n, n);
var avail = this["TLine"+n++];

thank you, but now my problem is that whenever it duplicates a m.c it deletes the previous one-so I always only have one m.c on the screen
any ideas why?
thank you

You’re surely assigning the same depth when you call the [font=courier new]MovieClip.duplicateMovieClip()[/font] method! I fixed that in the code I posted above. :wink:

I actually used this code:

avail = TLine.duplicateMovieClip(“TLine”+number, number++);

Do not use reserved (key)words! Use a different name for the variable!! :stuck_out_tongue:

var avail = TLine.duplicateMovieClip("TLine"+n, n++);

I’m using this code and still recieving the same results:
avail=Tline.duplicateMovieClip(“TLine”+num++);

maybe when I’m searching for the lines I’m supposed to be specifying the layer? here’s my code for searching for an available line

function findAvailable(mc)
{
for (var i=1; i<=num; i++)
{

if (mc==“TLine”)
{
line= this[“TLine” + i ];
if(line._x==origLine33X && line._y==origLine33Y)
{
return line;
}
}

thank you

It would be easier for me if you could attach your FLA. :stuck_out_tongue:

here it is-thanks
I’m working with the 33" shelf/frame -the smallest one -on the left side it’s called frame33-and it’s corresponding line is TLine
thanks

kode-were you able to access the file?

Yeah, sorry… got a little bit busy. :-\

I’ll check it out now. :slight_smile:

do you think If I put them all into an array it will remain on the screen? or that shouldn’t make a difference?

thanks