# Motion using actionscript

**URL:** <https://forum.kirupa.com/t/motion-using-actionscript/6642>\
**Category:** flash\
**Created:** [October 13, 2002, 1:33am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642 "2002-10-13T01:33:52Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mr\_JedI69](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@Mr\_JedI69](https://forum.kirupa.com/u/Mr_JedI69)\
**Post date:** [October 13, 2002, 1:33am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/1 "2002-10-13T01:33:52Z")

</div>

ok if :

onClipEvent(enterFrame) {  
speed = -3;  
this.\_x += speed;  
if(\_x\<-10 ){  
\_x=810;  
}  
}

makes an object going from right to left loop over and keep goign and going, then what do i change in the script to make an object going from left to right to keep looping over and going and going, and also for down to up and up to down, sorry ima flash newbie rofl:(

---

<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:** [October 13, 2002, 1:41am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/2 "2002-10-13T01:41:29Z")

</div>

Well I am not sure I 100% understand what you are trying to do, but I will give it a whirl.

First off, you can change your code above to say this…

```auto
onClipEvent (enterFrame) {
	speed = 3;
	this._x -= speed;
	if (_x<-10) {
		_x = 810;
	}
}

```

And to make it go the other way, add this…

```auto
onClipEvent (enterFrame) {
	speed = 3;
	this._x += speed;
	if (_x>810) {
		_x = -10;
	}
}

```

---

<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:** [October 13, 2002, 1:52am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/3 "2002-10-13T01:52:47Z")

</div>

ok ill explain, i have an object moving across the screen ( right to left) but when it gets to the end i want it to loop, you know what im saying? well i got it to loop but i can’t do do the same for an object moving left to right

---

<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:** [October 13, 2002, 1:56am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/4 "2002-10-13T01:56:02Z")

</div>

The second example I gave you above does just that. It moves your object from -10 \_x all the way to 810 \_x, once it reaches 810, it sends the clip back to -10 and the process starts over.

---

<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:** [October 13, 2002, 1:58am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/5 "2002-10-13T01:58:45Z")

</div>

thank you very much, sorry for all the comotion im a flash newbie lol

---

<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:** [October 13, 2002, 2:01am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/6 "2002-10-13T02:01:10Z")

</div>

No problem. I am the one that stated I wasn’t exactly sure if that was what you wanted.

I am glad I could help you out.

---

<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:** [October 13, 2002, 2:03am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/7 "2002-10-13T02:03:23Z")

</div>

wow never mind that thing u gave me didn’t work, my image width is 300 pixels and the height is 100 pixels, i have an object starting on the left side, i want it to start on the left and move to the right and when it hit’s the end i want it to go back to where it started and move to the right again, like loop

---

<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:** [October 13, 2002, 2:07am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/8 "2002-10-13T02:07:19Z")

</div>

All you have to do is change the numbers around to make them bigger or smaller.

It does what you are saying, you just need to adjust the numbers so it loops at the right time.

---

<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:** [October 13, 2002, 2:10am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/9 "2002-10-13T02:10:07Z")

</div>

thats where im having trouble lol ill try things then if i have problems ill ask u 🙂

---

<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:** [October 13, 2002, 2:12am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/10 "2002-10-13T02:12:08Z")

</div>

Here, check my example .fla (for flash MX, Flash 5 can not open MX files)

Just view the attachment on this post and I think it does what you wanted.

---

<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:** [October 13, 2002, 2:26am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/11 "2002-10-13T02:26:56Z")

</div>

hmm nothin seems to work even when i look at your example  
thats what im making, i want all the boxes to move then loop but i can only get the right box to do it

---

<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:** [October 13, 2002, 2:40am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/12 "2002-10-13T02:40:05Z")

</div>

Here, try the new .fla I posted.

---

<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:** [October 13, 2002, 2:42am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/13 "2002-10-13T02:42:19Z")

</div>

thanks so much man, i see whati wasn’t changing and why it didn’t work, not only did u help me alot, but u tought me some stuff thanks man 🙂 i owe you one lol

---

<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:** [October 13, 2002, 2:45am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/14 "2002-10-13T02:45:40Z")

</div>

No problem man. I am glad I could help you out. AS motion rules! Much better than tweening 😛

---

<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:** [October 13, 2002, 2:53am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/15 "2002-10-13T02:53:26Z")

</div>

ya i’d have to say, now time for me to learn new techniques using action script, i just don’t know where to start or what to try rofl

---

<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:** [October 13, 2002, 2:57am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/16 "2002-10-13T02:57:27Z")

</div>

Experimentation is the best way to actually learn what things do 🙂

Just try things out and experiment some. Be as evil as you would like :evil:

---

<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:** [October 13, 2002, 3:25am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/17 "2002-10-13T03:25:40Z")

</div>

hehe ya, i guess i better get learning AS before i start trying new stuff tho

---

<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:** [October 13, 2002, 3:38am UTC](https://forum.kirupa.com/t/motion-using-actionscript/6642/18 "2002-10-13T03:38:17Z")

</div>

This site is the best place to learn 😛
