# How to add random mc from library?

**URL:** https://forum.kirupa.com/t/how-to-add-random-mc-from-library/293813
**Category:** flash
**Created:** [August 4, 2009, 9:06am UTC](https://forum.kirupa.com/t/how-to-add-random-mc-from-library/293813 "2009-08-04T09:06:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![fjckls](https://avatars.discourse-cdn.com/v4/letter/f/ecc23a/32.png) [@fjckls](https://forum.kirupa.com/u/fjckls)
#### Post date: [August 4, 2009, 9:06am UTC](https://forum.kirupa.com/t/how-to-add-random-mc-from-library/293813/1 "2009-08-04T09:06:24Z")

</div>

Hi,  
How to add random movie clip to stage from many different movie clips in library?  
If I wanted to add one movie clip to stage I would do liko so:

```auto
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); 
function onMove(e:MouseEvent):void {     
var mc:MovieClip = new Ball();     
mc.x = mouseX;     
mc.y = mouseY;     
addChild(mc); 
}

```

I tried following but with no success, no errors, but nothing happens - no mc’s are added to stage. I have 6 movie clips in library and they all are linked, exported for actionscript. On MouseOver I want to add random movie clip from those six movie clips to the stage. Am I going in wrong direction? Any thoughts how to achieve this?

```auto

var myArray:Array = [mc1, mc2, mc3, mc4, mc5, mc6]; 
stage.addEventListener(MouseEvent.MOUSE_OVER, onLoop); 
function onLoop(e:MouseEvent):void {     
for (var i:int = 0; i< myArray.length; i++) {
         var randomMc:Number = Math.floor(Math.random()*i);
         var mc:MovieClip = new myArray[randomMc];
         addChild(mc);
         mc.x = mouseX;
         mc.y = mouseY;
     }
 }

```

Thank you.
