Stopping a function with a button?

Hi,

I appreciate any help, I’m pretty new to flash, and slowly working my way through it!

I’m trying to create a simple ‘drum machine’ game, where certain keys trigger sounds. I have that part down, but now I am trying to add different ‘kits’. I was attempting to do this by simply creating a button to advance to a different frame on my timeline, with different actionscript that calls the new sounds in.

This is my simple AS to play a sound.

//KICK
var sndKick1:Kick1 = new Kick1();
stage.focus = this;
addEventListener(
    KeyboardEvent.KEY_DOWN,
    function(evt:KeyboardEvent):void {
        switch(evt.charCode) {
            case 75:
            case 107:
                sndKick1.play(1);
                kick_mc.play();
                break;
        }
    }
);

The problem I’m having though, is that when I hit the button to advance to a new frame, with different AS, the previous functions are still active, and the sounds overlap. So I need my button to somehow stop the function (seen above) and gotoAndPlay the next.

Let me know if that makes any sense!