# Game animation

**URL:** <https://forum.kirupa.com/t/game-animation/240560>\
**Category:** flash\
**Created:** [October 4, 2007, 1:12am UTC](https://forum.kirupa.com/t/game-animation/240560 "2007-10-04T01:12:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BaconIsGood4You](https://avatars.discourse-cdn.com/v4/letter/b/50afbb/32.png) [@BaconIsGood4You](https://forum.kirupa.com/u/BaconIsGood4You)\
**Post date:** [October 4, 2007, 1:12am UTC](https://forum.kirupa.com/t/game-animation/240560/1 "2007-10-04T01:12:21Z")

</div>

I’m just learning AS3 and for an assignment I’m making a very basic brawler. I’m already beginning and I’ve run into a bump, and the kicker is I know how to do it easily in AS2 .

My issue is getting the punch animation to play all the way through no matter how quick the button is pushed. IE, I’ll click space (the punch button) and it’ll only play the first couple frames of the animation. How can I get it to play the whole animation?

I have my animations stored on separate frames in the movie clip playerHolder. By using gotoAndStop() I plan on accessing them.

I detect the space press and set a variable, punchVar to 1.

```auto

            if(e.keyCode == Keyboard.SPACE)
            {
                punchVar = 1;
                
            }

```

This is used in the function punchLaunch which is checked for in an Enter Frame listener.

```auto

this.addEventListener(Event.ENTER_FRAME, punchLaunch);

```

When punchVar is 1, play the punch and set punchVar to 0 (to stop the Enter Frame from continuously repeating the first frame). When the punch animation = 6 I want it to go back to the idle animation.

```auto

        private function punchLaunch(e:Event):void
        {
            
            if(punchVar == 1)
            { 
                playerHolder.punch();
                punchVar = 0;
                
                
            }
            
            if(playerHolder.playerPunch.currentFrame == 6)
            {
                playerHolder.gotoAndStop(1);
                
            }
        }

```

I’m stumped on this. Any help would be greatly appreciated.
