How to stop a function inside a MC?

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

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:


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