# X Movement Action Script

**URL:** <https://forum.kirupa.com/t/x-movement-action-script/21438>\
**Category:** flash\
**Created:** [May 21, 2003, 4:40pm UTC](https://forum.kirupa.com/t/x-movement-action-script/21438 "2003-05-21T16:40:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blakew](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/blakew/32/229_2.png) [@blakew](https://forum.kirupa.com/u/blakew)\
**Post date:** [May 21, 2003, 4:40pm UTC](https://forum.kirupa.com/t/x-movement-action-script/21438/1 "2003-05-21T16:40:27Z")

</div>

Could someone please tell me how to get the xmovement action script to loop?

This is the code I am using at the moment:

onClipEvent(enterFrame) {  
speed = 1;  
this.\_y += speed;  
}

Thank you.

---

<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:** [May 21, 2003, 5:25pm UTC](https://forum.kirupa.com/t/x-movement-action-script/21438/2 "2003-05-21T17:25:48Z")

</div>

I’ve added the code:

onClipEvent(enterFrame) {  
speed = 1;  
this.\_y += speed;  
}

---

<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:** [May 22, 2003, 9:29pm UTC](https://forum.kirupa.com/t/x-movement-action-script/21438/3 "2003-05-22T21:29:50Z")

</div>

hi there  
the answer is easy you only have to tell your movie clip that when the y coordinate gets to the final point you want it gets back to the beggining  
suppose we want a movieclip to move from point 0 to point 100

onClipEvent(enterFrame) {  
speed = 1;

if this.\_y\>=100{  
this.\_y=0  
this.\_y += speed;}  
else  
{

i hope i could be helpful  
this.\_y += speed;}  
}

---

<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:** [May 22, 2003, 9:51pm UTC](https://forum.kirupa.com/t/x-movement-action-script/21438/4 "2003-05-22T21:51:09Z")

</div>

Hello:

For some I couldn’t get your code to work.  
But, I thank you for your help.

I ended up using the following code:

onClipEvent(load){  
origY = this.\_x = 1;  
}

onClipEvent(enterFrame) {  
speed = 1;  
this.\_x \> 300 ? this.\_x = origY : this.\_x += speed;  
}

Thanks 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:** [May 22, 2003, 10:10pm UTC](https://forum.kirupa.com/t/x-movement-action-script/21438/5 "2003-05-22T22:10:20Z")

</div>

This’ll do the same thing that your code does, just without the variable.  
I’d do this:  
[AS]  
onClipEvent(load){  
speed=1;  
\_x=1;  
}  
onClipEvent(enterFrame){  
\_x+=speed;  
if(\_x\>=300){  
\_x=1;  
}  
[/AS]
