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?