# gotoAndStop - Easy Problem to Fix( I think )



## Overulle (May 12, 2009)

Heya guys,
I'm kinda new on ActionScript 3.0 and I want to update my web site from AS 2.0 to AS 3.0, because a part of it is in 3.0. 
What I'm trying to do is a simple gotoAndStop function, but it's not working.

Screen Shot Here

My buttons are called:
me_btn
works_btn
contacts_btn

And one thing I noticed, is that the stop(); is not working now.

The screen shot may not help at all, soo I'm going to tell what I did, as well.

I've put on stage the 3 buttons as a graphic(png default), and then I converted one by one to button, like. me_button graphic to me_btn and soo that to all buttons. 
Then I've inserted them into stage in Scene 1, after that I created a new layer called layer 2 and inserted this code:


```
me_btn.addEventListener(MouseEvent.CLICK, meClicked);
works_btn.addEventListener(MouseEvent.CLICK, worksClicked);
contacts_btn.addEventListener(MouseEvent.CLICK, contactsClicked);

function meClicked(me:MouseEvent):void
{
    this.gotoAndStop("Scene 1", 1);
}

function worksClicked(me:MouseEvent):void
{
     this.gotoAndStop("Scene 2", 1);
}

function contactsClicked(me:MouseEvent):void
{
      this.gotoAndStop("Scene 3", 1);
}

stop();
```
all this done, I selected the buttons in the stage and copy and past them in all scene's stages, and created a new layer named layer 2 and inserted that code too.

What am I doing wrong? And can you guys, help me fix this?


----------



## astacharles (Aug 14, 2006)

okay, the way you write it in AS3 is different, that's why it's not working for you. first off, if you have any sort of transitions or anything prior to the frame where you buttons start, you will need to create a layer and put a stop() function there. now, change your code for the buttons like this:

me.addEventListener(MouseEvent.CLICK, clickme);
function clickme(event:Event):void {
trace("me");
gotoAndStop("Scene1");
}
works.addEventListener(MouseEvent.CLICK, clickworks);
function clickworks(event:Event):void {
trace("works");
gotoAndStop("Scene2");
}
contact.addEventListener(MouseEvent.CLICK, clickcontact);
function clickcontact(event:Event):void {
trace("contact");
gotoAndStop("Scene3");
}

now make sure that you have named your frames for each of those exactly the way you've put them in the " " after gotoAndStop or you will get errors. i would remove the spaces as AS3 is very picky...

hope this helps, if it's still not working for your, message me or attach the flash file here and i will take a look at it for you.


----------

