# How to stop a function inside a MC?

**URL:** <https://forum.kirupa.com/t/how-to-stop-a-function-inside-a-mc/294359>\
**Category:** flash\
**Created:** [August 12, 2009, 11:54pm UTC](https://forum.kirupa.com/t/how-to-stop-a-function-inside-a-mc/294359 "2009-08-12T23:54:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SopaSeco](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@SopaSeco](https://forum.kirupa.com/u/SopaSeco)\
**Post date:** [August 12, 2009, 11:54pm UTC](https://forum.kirupa.com/t/how-to-stop-a-function-inside-a-mc/294359/1 "2009-08-12T23:54:12Z")

</div>

Hi, I need help with this, I try to stop a function inside a MC, I load a MC from my library and inside the MC i have this function how made he move aleatory by the time line.

this is the function

```auto
setInterval(aleFrames,100);

function aleFrames() {
    // generate a random number from 1 to 40
    var nRandom=Math.floor(Math.random()*40);

    // tell timeline to goto and play the random number 'nRandom'
    gotoAndStop(nRandom);
}

```

I load my MC from the Library with a loop:

```auto

var nrColumns:uint=19;
var holderArray:Array = new Array();

contenedor.x=107;
contenedor.y=120;
contenedor.alpha=.2;

for (var i:int=0; i<285; i++) {
    holderArray*=new Icons();
    if (i<nrColumns) {
        holderArray*.y=0;
        holderArray*.x=i*45+0;
    } else {
        holderArray*.y=holderArray[i-nrColumns].y+40;
        holderArray*.x=holderArray[i-nrColumns].x;
    }
    contenedor.addChild(holderArray*);
}

```

Now i have some buttons in my mainline and those open a window over the MC and made my animation really slow, but i need stop the alleFrames() and this one continue in the last frame it was and when i close the window the alleFrames() continue.

Sorry but my really bad english.

thnx
