# Auto move

**URL:** <https://forum.kirupa.com/t/auto-move/119544>\
**Category:** Uncategorized\
**Created:** [August 16, 2004, 7:28am UTC](https://forum.kirupa.com/t/auto-move/119544 "2004-08-16T07:28:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bahamutzero](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Bahamutzero](https://forum.kirupa.com/u/Bahamutzero)\
**Post date:** [August 16, 2004, 7:28am UTC](https://forum.kirupa.com/t/auto-move/119544/1 "2004-08-16T07:28:38Z")

</div>

ok ive been working on this code for …all day now…and for some reason i cannot get it to work. what im attempting to do is have this charactor move back and forth slowly (almost like a motion tween…through action script) maybe one of you could help me.

onClipEvent (enterFrame) {  
if (dir == “right”){  
this.\_x += 3; {  
if(this.\_x\>509) {  
dir=“left”;}}  
}  
if (dir==“left”){  
this.\_x -= 3;{  
if (this.\_x\<50) {  
dir = “right”;  
}}}

```
}
```

---

<div class="post-metadata">

**Author:** ![Skribble](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Skribble](https://forum.kirupa.com/u/Skribble)\
**Post date:** [August 16, 2004, 8:59am UTC](https://forum.kirupa.com/t/auto-move/119544/2 "2004-08-16T08:59:03Z")

</div>

just attach this to ur MC

```auto

 onClipEvent (load) {
 	Speed = 3;
 }
 onClipEvent (enterFrame) {
 	if (_x+Speed>500 || _x+Speed<0) {
 		Speed *= -1;
 	}
 	_x += Speed;
 }
 
 

```

---

<div class="post-metadata">

**Author:** ![Bahamutzero](https://avatars.discourse-cdn.com/v4/letter/b/5daacb/32.png) [@Bahamutzero](https://forum.kirupa.com/u/Bahamutzero)\
**Post date:** [August 16, 2004, 9:28am UTC](https://forum.kirupa.com/t/auto-move/119544/3 "2004-08-16T09:28:33Z")

</div>

that worked awesome man…thanks…i dont quite understand it but thanks lol

PS. How do you get that little code box…the quote box??

---

<div class="post-metadata">

**Author:** ![St\_Nick](https://avatars.discourse-cdn.com/v4/letter/s/bb73d2/32.png) [@St\_Nick](https://forum.kirupa.com/u/St_Nick)\
**Post date:** [August 16, 2004, 12:54pm UTC](https://forum.kirupa.com/t/auto-move/119544/4 "2004-08-16T12:54:51Z")

</div>

In advanced reply there are CODE tags.
