# Controlling the number of MC instances

**URL:** <https://forum.kirupa.com/t/controlling-the-number-of-mc-instances/200637>\
**Category:** flash\
**Created:** [September 13, 2006, 9:03pm UTC](https://forum.kirupa.com/t/controlling-the-number-of-mc-instances/200637 "2006-09-13T21:03:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Otomo](https://avatars.discourse-cdn.com/v4/letter/o/ecae2f/32.png) [@Otomo](https://forum.kirupa.com/u/Otomo)\
**Post date:** [September 13, 2006, 9:03pm UTC](https://forum.kirupa.com/t/controlling-the-number-of-mc-instances/200637/1 "2006-09-13T21:03:27Z")

</div>

Hi!  
I created this code to attach a MovieClip to the same position as the mouse.  
This works, but I don’t want to attach more than tree MC at the same time.

Shouldn’t this line be enough?

> for (var i = 0; i\<numbBombs; i++) {

> var stageWidth:Number = Stage.width;  
> var stageHeight:Number = Stage.height;  
> var numbBombs:Number = 3;  
> var gravity:Number = 5;  
> var movieBomb:MovieClip;  
> //  
> \_root.onEnterFrame = function() {  
> for (var i = 0; i\<numbBombs; i++) {  
> movieBomb = \_root.attachMovie(“bomb”, “bomb”+i, \_root.getNextHighestDepth());  
> movieBomb.\_x = \_xmouse;  
> movieBomb.\_y = \_ymouse;  
> movieBomb.onEnterFrame = falling;  
> }  
> };  
> //  
> function falling() {  
> this.\_y += gravity;  
> if (this.\_y\>stageHeight+10) {  
> delete this.onEnterFrame;  
> }  
> }
