# Help with movement animation

**URL:** https://forum.kirupa.com/t/help-with-movement-animation/64787
**Category:** programming
**Created:** [September 20, 2004, 1:40am UTC](https://forum.kirupa.com/t/help-with-movement-animation/64787 "2004-09-20T01:40:04Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![acor](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@acor](https://forum.kirupa.com/u/acor)
#### Post date: [September 20, 2004, 1:40am UTC](https://forum.kirupa.com/t/help-with-movement-animation/64787/1 "2004-09-20T01:40:04Z")

</div>

Please help me make it so when my character moves is plays the whole movement animation and not just one frame. Heres the code:

```auto
onClipEvent (load) {
moveSpeed = 4;
}
onClipEvent (enterFrame) {
if (Key.isDown (Key.RIGHT)) {
this._x += moveSpeed; _xscale = -100;
this.gotoAndPlay(1);
}
if (Key.isDown (Key.LEFT)) {
this._x -= moveSpeed; _xscale = 100;
this.gotoAndPlay(1)
}
 

```

the movemnt animation is 10 frames long but it only plays the first frame in the movie clip and then stops.

I want it to be something like this [http://baiwanfuong.notix.net/tienzsiyusi.htm](http://baiwanfuong.notix.net/tienzsiyusi.htm)

Please help me Chen!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 20, 2004, 6:57am UTC](https://forum.kirupa.com/t/help-with-movement-animation/64787/2 "2004-09-20T06:57:16Z")

</div>

hm i think that should work, you haven’t got a stop(); in any keyframes inside the movie clip have you? if u haven’t try:

onClipEvent (load) {  
moveSpeed = 4;  
}  
onClipEvent (enterFrame) {  
if (Key.isDown (Key.RIGHT)) {  
this.\_x += moveSpeed;  
\_xscale = -100;  
walking1 = true;  
}else{  
walking1 = false;  
}  
if (Key.isDown (Key.LEFT)) {  
this.\_x -= moveSpeed;  
\_xscale = 100;  
walking2 = true;  
}else{  
walking2 = false;  
}  
if(walking1 || walking2){  
this.gotoAndPlay(2);  
}else{  
this.gotoAndStop(1);  
}  
}  
\</pre\> you’ve probably put stop(); in the first keyframe of the walking movie clip haven’t u, that should be ok to delete if you use the above code. but if u want to keep it in the last keyframe of the movie clip you’ll need gotoAndPlay(2); else it’ll go to the first one and stop again.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [September 20, 2004, 7:07am UTC](https://forum.kirupa.com/t/help-with-movement-animation/64787/3 "2004-09-20T07:07:19Z")

</div>

This is just what I’ve been working with the last two weeks.  
I’ll give you an example of how mine works.  
I’ve got a movie clip of the character, where frame 1 is facing north, 2 contains a movie clip where he walks north, 3 is facing south, 4 is another movie clip where he walks south and so on.

onClipEvent (enterFrame) {  
if (Key.isDown(Key.LEFT)) {  
setProperty (this, \_x, this.\_x-5);  
if (\_currentframe != 6) {  
gotoAndStop(6);  
}  
}

This isn’t really how my code looks now, since I can only find an early version of my project here. But it works anyways.  
If you’re not in frame 6, which is the _walk left_ frame, it will go there. Since there is a movie clip inside the frame, gotoAndStop will work fine.
