# Auto move

**URL:** <https://forum.kirupa.com/t/auto-move/61120>\
**Category:** Uncategorized\
**Created:** [August 16, 2004, 7:28am UTC](https://forum.kirupa.com/t/auto-move/61120 "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/61120/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:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 16, 2004, 8:59am UTC](https://forum.kirupa.com/t/auto-move/61120/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:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 16, 2004, 9:28am UTC](https://forum.kirupa.com/t/auto-move/61120/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:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [August 16, 2004, 12:54pm UTC](https://forum.kirupa.com/t/auto-move/61120/4 "2004-08-16T12:54:51Z")

</div>

In advanced reply there are CODE tags.
