Hopefully this is a small problem.
I am working on a simple scrolling game. When the right key is pressed, the background scrolls and the character MC advances to the second frame of the man MC which contains an animation of the character walking. When the key is released, the background stops scrolling and the character returns to frame one of the man MC which he is just standing.
The problem I am having is that the walking animation does not play completely or loop. It plays for a few frames then stops.Code:stop(); function man_walks(e:KeyboardEvent):void { if (e.keyCode==Keyboard.RIGHT) { man_mc.gotoAndStop(2); } } stage.addEventListener(KeyboardEvent.KEY_DOWN, man_walks); function stop_man(e:KeyboardEvent):void { man_mc.gotoAndStop(1); } stage.addEventListener(KeyboardEvent.KEY_UP, stop_man);
I think the problem is that the script (gototAndStop(2); ) repeats as long as the key is pressed, meaning it continues to return and stop on frame 2 causing the walk cycle to pause.
Is this what is causing the walk cycle not to animate? How do I get around this?
I’ve attached a small example showing the problem.




Reply With Quote