 # Decelerating spring effect?

does anybody know how to make a decelerating spring effect? what i want is to have a ball that goes to a target using the spring effect (ie it goes a bit further than the target and springs back a bit before a few times decreasing each time the distance - giving a spring effect) - but what i also want is that as it goes to the first position where it ‘springs’ back for the ball to decelerate!

I can do the spring - i can do the deceleration - but I dont know how to do the 2 together - :h:

// my spring effect -

this._y = 200;
this._x = 100;
targetX = 300;
mover = 0;
loop = 0;
}
onClipEvent (enterFrame) {
if (_root.go == 1) {
mover = mover+(targetX-this._x)/2;
mover=mover *.6;
this._x = this._x+mover;
loop=loop+1;
_root.where=_x;
}
}

// my deceleration

movedx = 0;
targetX = 300;
}

onClipEvent (enterFrame) {
distX = targetX-this._x;
totalDistance = Math.sqrt(distXdistX);
this._x += distX
speed;
if (totalDistance<1) {
this._x = targetX;
}
}

Any help much appreciated!

not too difficult
you just have to set movetype =“spring” on the way out and
= “decel” on the way back
[AS]
// my spring effect -

this._y = 200;
this._x = 100;
targetX = 300;
mover = 0;
loop = 0;

movedx = 0;
targetX = 300;
}
onClipEvent (enterFrame) {
if ( movetype == “spring” ){

if (_root.go == 1) {
mover = mover+(targetX-this._x)/2;
mover=mover *.6;
this._x = this._x+mover;
loop=loop+1;
_root.where=_x;
}

}
else if (movetype==“decel”){
distX = targetX-this._x;
totalDistance = Math.sqrt(distXdistX);
this._x += distX
speed;
if (totalDistance<1) {
this._x = targetX;
}
}

}
[/AS]

or maybe try the spring tutorial found… OH WAIT! RIGHT HERE ON KIRUPA.COM!!! how nifty is that? (heres a link)

http://www.kirupa.com/developer/actionscript/spring.htm

thanks everyone and merry christmas and happy new year - dont work too hard!