# Duplicate MCs and PLace Randomly

**URL:** <https://forum.kirupa.com/t/duplicate-mcs-and-place-randomly/286524>\
**Category:** flash\
**Created:** [April 16, 2009, 4:58pm UTC](https://forum.kirupa.com/t/duplicate-mcs-and-place-randomly/286524 "2009-04-16T16:58:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stanmc](https://avatars.discourse-cdn.com/v4/letter/s/b77776/32.png) [@stanmc](https://forum.kirupa.com/u/stanmc)\
**Post date:** [April 16, 2009, 4:58pm UTC](https://forum.kirupa.com/t/duplicate-mcs-and-place-randomly/286524/1 "2009-04-16T16:58:26Z")

</div>

Hi - I want to attach a mc from the library, then duplicate it 2-3 times, and have the duplicates start in random \_x / \_y locations on the stage. They then slowly drift across stage.

The code I’ve got so far loads the mc from the library, duplicates it once, and places it randomly. But it only creates one duplicate instead of 2 or 3. And I suspect it could be simplified.

So I need corrected code to create 2 or 3 duplicates, and have them start randomly and move at the same speed across stage. Maybe advice on how to allow them to move at different speeds would be useful as well.

Thanks for your time and help.

```auto

this.createEmptyMovieClip("box_mc", 10);
this.attachMovie("box", "box_mc", 10);
box_mc._x = Math.random()*300;
box_mc._y = Math.random()*100;

box_mc.onEnterFrame = function () {
	speed = .5;
	this._x += speed;
}

for (var i:Number = 0; i < 4; i++) {
	var newMovie:MovieClip = duplicateMovieClip(box_mc, "box_mc" + i,this.getNextHighestDepth());
}

box_mc1.onEnterFrame = function () {
	speed = .5;
	this._x += speed;
}
box_mc1._x = Math.random()*300;
box_mc1._y = Math.random()*100;

box_mc2.onEnterFrame = function () {
	speed = .5;
	this._x += speed;
}
box_mc2._x = Math.random()*300;
box_mc2._y = Math.random()*100;

box_mc3.onEnterFrame = function () {
	speed = .5;
	this._x += speed;
}
box_mc3._x = Math.random()*300;
box_mc3._y = Math.random()*100;

```

FLA attached.
