Animating a sprite in AS3. help needed

hi,

i know this will be pretty simple for most of you but i am a beginner. i am trying to animate a sprite to walk when i press the arrow key. when the arrow key is pressed the sprite moves across the stage but does not animate (simulate walking) until the button is released.this is the code:

//define variables, false by default
var keyLeft:Boolean;
var keyRight:Boolean;

//add keyboard event listeners to the stage that listen for keyboard key presses
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);

//give you motion whenever keyLeft or keyRight is set to true;
addEventListener(Event.ENTER_FRAME,moveObject);

//when key is pressed down
function keyDownFunction(evt:KeyboardEvent) {
if (evt.keyCode == 37) {
keyLeft = true;
}
if (evt.keyCode == 39) {
keyRight = true;

}
}

function keyUpFunction(evt:KeyboardEvent) {
if (evt.keyCode == 37) {
keyLeft = false;
}
if (evt.keyCode == 39) {
keyRight = false;

}
}

//comes into play whenver keyLeft or keyRight is set to true
function moveObject(evt:Event) {
if (keyLeft) {

ryu_mc.x -= 5;
ryu_mc.gotoAndStop('walking')

} else if (keyRight) {

ryu_mc.x += 5;
ryu_mc.gotoAndStop(“walking”);

}
}

any help would be appreciated. cheers.

Okay what is at the walking frame is there any animation there? because at the moment your just moving ur sprite in the horizontal direction and then stopping it on frame labled walking

I personally think as2 would be the answer to your problem.