im making this game and im trying to make it that when you press the down key the character will move down and will animate it walking down and as soon as the key is released the character will stop animating and stop moving. I have the main movieclip with this code (all im working on now is the downwards movement)
onClipEvent(load){
speed = 5;
}
onClipEvent(enterFrame){
if(Key.isDown(Key.DOWN)){
this._y += speed;
this.gotoAndStop(1);
}else if(Key.isDown(Key.UP)){
this._y -= speed;
this.gotoAndStop(2);
}else if(Key.isDown(Key.RIGHT)){
this._x += speed;
this.gotoAndStop(4);
}else if(Key.isDown(Key.LEFT)){
this._x -= speed;
this.gotoAndStop(3);
}
}
and on frame 1 of the movieclip is another movieclip with this code (this movieclip is the animating one. I put this code on the movieclip so when it checks if the down key is not being pressed, it will go to frame 1 of this movieclip and stop. This is to make the character to stop facing the direction it was just moving)
onClipEvent (enterFrame) {
if (!Key.isDown(Key.DOWN)) {
this.gotoAndStop(1);
}
}
What is happening is the walking down animation isnt playing when i have the down key pressed.