# Put a mc into a variable

**URL:** <https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803>\
**Category:** Uncategorized\
**Created:** [October 23, 2003, 7:25pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803 "2003-10-23T19:25:33Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![tziviak](https://avatars.discourse-cdn.com/v4/letter/t/5f9b8f/32.png) [@tziviak](https://forum.kirupa.com/u/tziviak)\
**Post date:** [October 23, 2003, 7:25pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/1 "2003-10-23T19:25:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 23, 2003, 8:10pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/2 "2003-10-23T20:10:51Z")

</div>

There are a few options:

```auto
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++];

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2003, 2:34am UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/3 "2003-10-24T02:34:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2003, 2:47am UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/4 "2003-10-24T02:47:42Z")

</div>

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. 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2003, 1:40pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/5 "2003-10-24T13:40:14Z")

</div>

I actually used this code:

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 24, 2003, 5:14pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/6 "2003-10-24T17:14:26Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 26, 2003, 3:43pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/7 "2003-10-26T15:43:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 26, 2003, 8:30pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/8 "2003-10-26T20:30:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 26, 2003, 10:10pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/9 "2003-10-26T22:10:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 27, 2003, 7:29pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/10 "2003-10-27T19:29:55Z")

</div>

kode-were you able to access the file?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 27, 2003, 10:14pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/11 "2003-10-27T22:14:58Z")

</div>

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

I’ll check it out now. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [November 10, 2003, 7:30pm UTC](https://forum.kirupa.com/t/put-a-mc-into-a-variable/33803/12 "2003-11-10T19:30:29Z")

</div>

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
