AS3 beat em up, need help with attacking!

Ok, hello my name is matt, and im currently making an “AS3 beat em up” ala streets of rage or double dragon.

Currently i have my character moving and a few animations done and i am trying to figure out how to make attacks work.

I have some “basic” animation for his attack, but im not sure how to get it to work correctley.

What happens is, if you press control (the attack button) whilst the character is walking he just keeps moving and is stopped on the attack frame.

I want the character to stop moving if the attack is pressed and once it is released start moving again.

I am a relative “noob” when it comes to flash programming, I have had some experience making prototypes and i have built what i have based on the things i have learned making them.

Any help is very much appreciated and hopefully I can get this sorted out!

cheers, matt.

P.S, here is the code i am currently running!

hero.gotoAndStop(‘still’);
var left:Boolean = false;
var right:Boolean = false;
var up:Boolean = false;
var down:Boolean = false;
var attack:Boolean = false;
var speed:Number = 5;
var Aspeed:Number = 0;

stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
hero.addEventListener(Event.ENTER_FRAME, moveHero);

function moveHero(event:Event):void {
// Move up, down, left, or right
// if(left is true and right is not true)
if ( left) {

    hero.x -= speed;
    hero.scaleX = -1.3;
    if (hero.currentLabel!="walking") {
        hero.gotoAndStop("walking");
    }
}

// if(right is true and left is not true)
if ( right ) {
    hero.x += speed;
    hero.scaleX = 1.3;
    if (hero.currentLabel!="walking") {
        hero.gotoAndStop("walking");
    }
}
// if(up is true and down is not true)
if ( up ) {
    hero.y -= speed;
    if (hero.currentLabel!="walking") {
        hero.gotoAndStop("walking");
    }
}
// if(down is true and up is not true)
if ( down) {
    hero.y += speed;
    if (hero.currentLabel!="walking") {
        hero.gotoAndStop("walking");

    }
} if ( attack ) {
    hero.gotoAndStop("punching");
    hero.speed =0
}
if (!left && !right && !up && !down && !attack) {
    hero.gotoAndStop("still");
}

}

//this is the function the KeyboardEvent.KEY_DOWN listener uses
function keyPressed(event:KeyboardEvent):void {

switch ( event.keyCode ) {
    case Keyboard.UP :
        up = true;
        break;
    case Keyboard.DOWN :
        down = true;
        break;
    case Keyboard.LEFT :
        left = true;
        break;
    case Keyboard.RIGHT :
        right = true;
        break;
    case Keyboard.CONTROL :
        attack = true;
        
    default :
        break;
}

}
//this is the function the KeyboardEvent.KEY_UP listener uses
function keyReleased(event:KeyboardEvent):void {
switch ( event.keyCode ) {
case Keyboard.UP :
up = false;
break;
case Keyboard.DOWN :
down = false;
break;
case Keyboard.LEFT :
left = false;
break;
case Keyboard.RIGHT :
right = false;
break;
case Keyboard.CONTROL :
attack = false;
default :
break;
}
}