# Punch Problem

**URL:** <https://forum.kirupa.com/t/punch-problem/291954>\
**Category:** programming\
**Created:** [July 8, 2009, 8:54am UTC](https://forum.kirupa.com/t/punch-problem/291954 "2009-07-08T08:54:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JTurner](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@JTurner](https://forum.kirupa.com/u/JTurner)\
**Post date:** [July 8, 2009, 8:54am UTC](https://forum.kirupa.com/t/punch-problem/291954/1 "2009-07-08T08:54:16Z")

</div>

hy

i am trying to make a character punch and kick, i have the code to work but when i enter the movement code in and then try to press 1 and 2, nothing happens, the actions are cancelling each other out or they are having an effect on each other but i still cant find a way to fix it, here is my code

```php
walkspeed = 5;
walk = true;

up = 38;
down = 40;
backward = 37;
forward = 39;
punchcombo = 49; // keyboard 1 for punch combo
kick= 50; // keyboard 2 for kick
jumpkey = 51;// keyboard 3 for jump

function movement () {
    moving = false;

    if(Key.isDown(Key.RIGHT)){
    hero._x += walkspeed;
    hero._xscale = 100;
    moving = true;
    }
        
    if(Key.isDown(Key.LEFT)){
    hero._x -= walkspeed;
    hero._xscale = -100;
    moving = true;
    }

    if(Key.isDown(Key.UP)){
    hero._y -= walkspeed;
    moving = true;
    }

    if(Key.isDown(Key.DOWN)){
    hero._y += walkspeed;
    moving = true;
    }
    
    if(!moving && !attacks) {
        hero.gotoAndStop("stance")
    }
    
    function attacks() {
        if(hero.attack)
        return;
        
        if (Key.isDown(punchcombo)) {
        hero.gotoAndStop("punch"); // if there's no combo, then the normal attack is played
        hero.attack = true;
        }

        if (Key.isDown(kick)) {
        hero.gotoAndStop("kick");
        hero.attack = true;
    }
    }
};

//------------------------
onEnterFrame = function () {
    //trace(Key.getCode());
        movement();
    attacks();
};

```

and also heres my fla and swf

[http://www.swfupload.com/view/104612.htm](http://www.swfupload.com/view/104612.htm) - swf  
[http://www.sendspace.com/file/ib7nns-](http://www.sendspace.com/file/ib7nns-) fla

thanks in advance =)
