# AS2 to AS3 duplicate random MC

**URL:** <https://forum.kirupa.com/t/as2-to-as3-duplicate-random-mc/316515>\
**Category:** flash\
**Created:** [November 24, 2010, 5:37am UTC](https://forum.kirupa.com/t/as2-to-as3-duplicate-random-mc/316515 "2010-11-24T05:37:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sakura](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Sakura](https://forum.kirupa.com/u/Sakura)\
**Post date:** [November 24, 2010, 5:37am UTC](https://forum.kirupa.com/t/as2-to-as3-duplicate-random-mc/316515/1 "2010-11-24T05:37:52Z")

</div>

Hello, it’s been a long long time since a post.  
Well I was playing with Flash8, doing this tutorial ([**http://www.kirupa.com/developer/actionscript/duplicate.htm**](http://www.kirupa.com/developer/actionscript/duplicate.htm)), all is well.

Then I tried Flash CS4 and the AS doesn’t work, a lot has changed from AS2 to AS3. Well a lot for me, since programming is my weak point.

Anyways, here is the AS. How do I re-write so it will work with AS3?

```auto
onClipEvent (load) {
	scale = (random(100) + 50)

	this._x = random(600);
	this._y = random(250);
	this._alpha = random(100);
	this._xscale = scale;
	this._yscale = scale;
}

```

and within the MC timeline

```auto
//duplicate the sqare by 9times, and amout is >0
amount = 9;
   while(amount>0) {
//The target identifier is the name of the movie 
//clip that you choose to copy	  
//The second identifier gives a name to the duplicated movie clip
//Movie depth refers to the vertical stacking order of the new duplicate movie clip
   duplicateMovieClip (_root.square, "square" + i, i);
   i = i + 1;
   amount = amount-1;
}

```

Thank you
