# Scripted movement, how to stop?

**URL:** <https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731>\
**Category:** Uncategorized\
**Created:** [March 29, 2006, 4:13pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731 "2006-03-29T16:13:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![azuuh](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@azuuh](https://forum.kirupa.com/u/azuuh)\
**Post date:** [March 29, 2006, 4:13pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731/1 "2006-03-29T16:13:57Z")

</div>

so i have a MC called “pala” and a button called “nappi” … i have the following script in the first frame of the movie and everything works how it should, but how do i get the “pala” stop moving when it reaches the property -307 ?

var speed:Number = 8;

pala.startMove = function()  
{  
this.onEnterFrame = function()  
{  
this.\_x -= speed;  
}  
}

pala.stopMove = function()  
{  
delete this.onEnterFrame  
}

nappi.onRollOver = function()  
{  
pala.startMove();  
}

nappi.onRollOut = function()  
{  
pala.stopMove();  
}

---

<div class="post-metadata">

**Author:** ![LoungeActx](https://avatars.discourse-cdn.com/v4/letter/l/71c47a/32.png) [@LoungeActx](https://forum.kirupa.com/u/LoungeActx)\
**Post date:** [March 29, 2006, 4:15pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731/2 "2006-03-29T16:15:53Z")

</div>

Maybe this would be better using a scripted tween?

---

<div class="post-metadata">

**Author:** ![azuuh](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@azuuh](https://forum.kirupa.com/u/azuuh)\
**Post date:** [March 29, 2006, 4:20pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731/3 "2006-03-29T16:20:20Z")

</div>

well it wont work picuse i have two buttons and two frames and it will be like a sliding menu or something like that so id needto script it with something like if (getproperty = … or something 😕  
im just too noob to get it work:\<

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [March 29, 2006, 5:16pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731/4 "2006-03-29T17:16:13Z")

</div>

I dont know what you mean “reaches the property -307”. There are numerous properties of a movieclip. Let’s say you mean you want it to stop when the \_x is past -307. It would be [AS]var speed:Number = 8;  
nappi.onRollOver = function()  
{  
pala.onEnterFrame = function()  
{  
this.\_x \<= -307 ? delete this.onEnterFrame : this.\_x -= speed;  
}  
}  
nappi.onRollOut = function()  
{  
delete pala.onEnterFrame;  
}[/AS]

---

<div class="post-metadata">

**Author:** ![azuuh](https://avatars.discourse-cdn.com/v4/letter/a/e47c2d/32.png) [@azuuh](https://forum.kirupa.com/u/azuuh)\
**Post date:** [March 29, 2006, 6:03pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731/5 "2006-03-29T18:03:02Z")

</div>

ah. sorry i wasnt clear enough, but the \_x past -307 was correct :\>  
it works now, thank you alot!

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [March 29, 2006, 8:58pm UTC](https://forum.kirupa.com/t/scripted-movement-how-to-stop/183731/6 "2006-03-29T20:58:19Z")

</div>

No prob!
