# \[Flash8\]~ duplicateMovieClip using a variable?

**URL:** <https://forum.kirupa.com/t/flash8-duplicatemovieclip-using-a-variable/221832>\
**Category:** flash\
**Created:** [April 8, 2007, 10:55am UTC](https://forum.kirupa.com/t/flash8-duplicatemovieclip-using-a-variable/221832 "2007-04-08T10:55:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![laver2k](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/laver2k/32/3320_2.png) [@laver2k](https://forum.kirupa.com/u/laver2k)\
**Post date:** [April 8, 2007, 10:55am UTC](https://forum.kirupa.com/t/flash8-duplicatemovieclip-using-a-variable/221832/1 "2007-04-08T10:55:49Z")

</div>

Hey everyone.  
Ive coded something that plucks a colour randomly from an array.

After that, “ball\_mc” is added to the name. For example, the code generates “greenball\_mc” or “blueball\_mc”.

This string is then stored into a variable, newBall.  
So newBall holds “blueball\_mc” say.

Off of the stage are movieclips with instance name matching these variables. So a blueball\_mc movieclip.

How can I use newBall to duplicate the matching coloured movie clip?

This duplicates the greenball and puts it into a random place:  
**greenball\_mc.duplicateMovieClip** (“newBall”+i, i, {\_x:Math.random()\*150, \_y:Math.random()\*150, \_alpha:Math.random()\*50});

What I guess Im aiming for is:  
**newBall.duplicateMovieClip** (“newBall”+i, i, {\_x:Math.random()\*150, \_y:Math.random()\*150, \_alpha:Math.random()\*50});

But which syntax do I use to do this?
