# attachMovie and clear interval

**URL:** https://forum.kirupa.com/t/attachmovie-and-clear-interval/227443
**Category:** flash
**Created:** [May 30, 2007, 11:41am UTC](https://forum.kirupa.com/t/attachmovie-and-clear-interval/227443 "2007-05-30T11:41:24Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![force10x](https://avatars.discourse-cdn.com/v4/letter/f/d07c76/32.png) [@force10x](https://forum.kirupa.com/u/force10x)
#### Post date: [May 30, 2007, 11:41am UTC](https://forum.kirupa.com/t/attachmovie-and-clear-interval/227443/1 "2007-05-30T11:41:24Z")

</div>

Hi everyone,  
Im using attachMovie to load movieclips dynamically on the stage.  
this works fine except that there is always an extra movieClip on the top, left corner of the stage.

I am using a set interval to place the mc’s on stage at regular intervals.

I also have a clearInterval that is not getting triggered. I got the code for this from the flash help files.

my code for attachMovie is as follows:

```auto

var intervalId:Number;
 
function placeFrogs():Void {
 this.attachMovie("frog_id", "frog_mc", this.getNextHighestDepth());
 this.frog_mc._x = random (500)+ 10;
 this.frog_mc._y = random (450)+ 10;
}
 
//put the placefrogs function inside another function which will be triggered
//by the setInterval
 
function timerPlaceFrogs():Void{
 placeFrogs();
}
 
 
//this loads the frog_mc on the stage after approx 2 secs
 
function beginInterval():Void {
if(intervalId != null) {
 trace("clearInterval");
 clearInterval(intervalId);
 }

 intervalId = setInterval(timerPlaceFrogs, 1800);
}
beginInterval();
 

```

any pointers on where I am going wrong?  
Thank you .
