# Play frames before gotoAndPlay

**URL:** https://forum.kirupa.com/t/play-frames-before-gotoandplay/301383
**Category:** flash
**Created:** [December 8, 2009, 5:47pm UTC](https://forum.kirupa.com/t/play-frames-before-gotoandplay/301383 "2009-12-08T17:47:56Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![gregasus](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@gregasus](https://forum.kirupa.com/u/gregasus)
#### Post date: [December 8, 2009, 5:47pm UTC](https://forum.kirupa.com/t/play-frames-before-gotoandplay/301383/1 "2009-12-08T17:47:56Z")

</div>

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

```auto

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

```auto

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!
