Scripted movement, how to stop?

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();
}

Maybe this would be better using a scripted tween?

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 :confused:
im just too noob to get it work:<

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]

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

No prob!