Right, Left

ok here is the thing, I have a guy which moves depending on the keypress, right left, etc.

but the problem is that I have 4 frames within the main movie clip (the main character). The 1st frame is him standing still facing to the right, second frame is him standing still facing to the left, third is facing right but with walking animation, 4th frame is him facing left but with a walking animation. So how do I do it that if the char. was walking to the right and the user lets go of the right key the main character keeps facing that way, same with left, if the char was walking to the left, and the user lets go of the left key he faces left.

This is the code I have, but its not working:

onClipEvent (enterFrame) {

if (Key.isDown(Key.LEFT)) {
	_x -= speed;
	this.gotoAndStop("walkleft");
}else{
            this.gotoAndStop("stillleft");
    }
if (Key.isDown(Key.RIGHT)) {
	_x += speed;
	this.gotoAndStop("walkright");
}else{
            this.gotoAndStop("stillright");
    }  

}

Please help, thanks