Play frames before gotoAndPlay

Hello everyone,

I’m currently breaking my head over an issue I have with a site I am making in Flash.
After I click a button I need it to play a number of frames before doing a gotoAndPlay.

I tried to do this with two variables and then change them in a function.
this is the code


stop();
var previousPage:String = "home";
var currentPage:String= "";

function gotoPage(about)
{
    var previousPage = currentPage;
    var currentPage = "about";
    this.gotoAndPlay(previousPage + "-out");
}

bthome.addEventListener(MouseEvent.CLICK, gotoPage);
btabout.addEventListener(MouseEvent.CLICK, gotoPage);
btmusic.addEventListener(MouseEvent.CLICK, gotoPage);
btlyrics.addEventListener(MouseEvent.CLICK, gotoPage);

And then after the frames I needed it to play


stop();

addEventListener(Event.ENTER_FRAME, homeout);
function homeout(evtObj:Event)
{
    gotoAndStop(currentPage);
}

There probably is a simple way to do this but I’m fairly new to AS3.0, any help would be very much appreciated!