# Help with movement script:

**URL:** <https://forum.kirupa.com/t/help-with-movement-script/25726>\
**Category:** Uncategorized\
**Created:** [July 16, 2003, 12:40am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726 "2003-07-16T00:40:55Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![xmattx](https://avatars.discourse-cdn.com/v4/letter/x/6de8d8/32.png) [@xmattx](https://forum.kirupa.com/u/xmattx)\
**Post date:** [July 16, 2003, 12:40am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/1 "2003-07-16T00:40:55Z")

</div>

im using this

onClipEvent (load) {  
speed = 5;  
}  
onClipEvent (enterFrame) {  
if (this.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
// /////////////  
if (\_root.hitbar.\_x\>\_root.\_xmouse) {  
\_root.hitbar.\_x = \_root.hitbar.\_x-((\_root.hitbar.\_x-\_root.\_xmouse)/speed);  
}  
}  
if (\_root.hitTest(\_root.\_xmouse, \_root.\_ymouse)) {  
if (\_root.hitbar.\_x\<\_root.\_xmouse) {  
\_root.hitbar.\_x = \_root.hitbar.\_x+((\_root.\_xmouse-this.hitbar.\_x)/speed);  
// /////////////////////////  
}  
}  
}

however I cant get the script to work  
Im placing this script on a movie clip, there is a second MC whose instance name is “hitbar” and when the mouse hits this MC it should trigger the first MC to travel along the X axis…

any help?

thanks!

---

<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:** [July 16, 2003, 5:26am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/2 "2003-07-16T05:26:18Z")

</div>

When you do the hitTest you have put a boolean value:

```auto

if(this.hitTest(_root._xmouse, _root._ymouse, true) == true){
 trace("Mouse hit!");
}

```

:-\

---

<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:** [July 16, 2003, 5:54am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/3 "2003-07-16T05:54:07Z")

</div>

i tried implementing the changes using that, i still cant get it tow work…

how are you using it in the entire script?

thanks.

---

<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:** [July 16, 2003, 6:12am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/4 "2003-07-16T06:12:45Z")

</div>

post your file so i can have a look at 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:** [July 16, 2003, 6:34am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/5 "2003-07-16T06:34:19Z")

</div>

i sorta got the script to work, however its “jerky” amd has some undesirbale effects… I would like it to operate much smoother.

---

<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:** [July 16, 2003, 7:08am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/6 "2003-07-16T07:08:05Z")

</div>

Do you want the pink MC follow the mouse when the mouse is over the grey MC? If yes then I think you should take a look at this!

---

<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:** [July 16, 2003, 1:15pm UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/7 "2003-07-16T13:15:01Z")

</div>

very nice, is there a way( withen the same script) to restrain the pink MC to only move be able to move to a certain x position? I dont want the pink MC to be able to move further than the hitarea box.

thanks so much.

---

<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:** [July 16, 2003, 1:17pm UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/8 "2003-07-16T13:17:48Z")

</div>

You can use conditional statements again for that. You can compare the \_x position and the width of the hit area MC as the borders. I’ll give your file shot tomorrow. I’ll have to take a rest! 🙂

In the meantime try to experiment with 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:** [July 16, 2003, 1:37pm UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/9 "2003-07-16T13:37:32Z")

</div>

word is bond. :beam:

---

<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:** [July 17, 2003, 2:14am UTC](https://forum.kirupa.com/t/help-with-movement-script/25726/10 "2003-07-17T02:14:10Z")

</div>

np
