# \[AS3\] gotoAndStop(?) wont work

**URL:** <https://forum.kirupa.com/t/as3-gotoandstop-wont-work/324165>\
**Category:** Uncategorized\
**Created:** [August 5, 2011, 5:13pm UTC](https://forum.kirupa.com/t/as3-gotoandstop-wont-work/324165 "2011-08-05T17:13:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kestor](https://avatars.discourse-cdn.com/v4/letter/k/13edae/32.png) [@kestor](https://forum.kirupa.com/u/kestor)\
**Post date:** [August 5, 2011, 5:13pm UTC](https://forum.kirupa.com/t/as3-gotoandstop-wont-work/324165/1 "2011-08-05T17:13:13Z")

</div>

Hello there.  
So i made an attack animation for my game character and placed it on the “X” button with the following code:

```auto

var xKeyIsDown:Boolean = false;

stage.addEventListener(KeyboardEvent.KEY_DOWN,PressAKey);
stage.addEventListener(KeyboardEvent.KEY_UP,ReleaseAKey);

function PressAKey(event: KeyboardEvent):void
{
     if(event.keyCode==Keyboard.X)
    {
        xKeyIsDown=true;
    }
}
function ReleaseAKey(event:KeyboardEvent):void
{
    if(event.keyCode==Keyboard.X)
    {
        xKeyIsDown=false;
    }
}

circle.addEventListener(Event.ENTER_FRAME, moveTheCircle);

function moveTheCircle(event:Event):void
{
    if(xKeyIsDown)
    {
        circle.gotoAndStop(5);
    }
}

```

So the problem with this is that when i am ingame and i push the x key the animation will stop on frame 1 (the attack animation i made), but i dont get why because theres no “stop()” code in the animation and the main time line code seems ok.

The code i wrote is cuted down so you see only the bits related to button X and the animation.

PS: sorry for my english.
