[CS3] Inertia/Friction Drag thing

Ok, I’m not sure where to start on this, but I’m looking for a car like momentum on a clip that rests on another one that can be dragged.
In this image:

The red area is a movieclip that can be dragged with the mouse horizontal only. The blue area is a movieclip that rests on top of the red one.
What I’d like to do is if the user drags the red clip slowly, then the blue one moves along with the red one evenly. However, if they drag the red one fast then the blue one slides back. So dragging the red fast to the right causes the blue to slide to the left. Also if the red one comes to a sudden stop, then I’d like the blue one to continue along for a bit. So if they are dragging to the right and then stop suddenly, the blue clip keeps sliding to the right for awhile…
This would all be similar to having something in a car that slides when you take off and stop suddenly. Also it will not go past the blockers on the right and left of the red clip.

Any help is much appreciated!:party:

maybe this will help
http://www.cove.org/ape/index.htm

Thanks. Yea, I’ve downloaded that and tried it out, but it’s kind of overkill for what I’m trying to do. I really don’t want to have to include all the extra lines of code required for that to work. I’ve got something going on that is kind of what I want, but not really…


var travelDistance = dragClip.x-lastDragX;
lastDragX=dragClip.x;
ammountToAdd+=travelDistance;
moveObject.x+=ammountToAdd/20;
ammountToAdd-=ammountToAdd/20;
//ammountToAdd=0;
if (moveObject.x<dragClip.x) {
  moveObject.x=dragClip.x;
}
else if (moveObject.tempX>dragClip.x+dragClip.width) {
  moveObject.x=dragClip.x+dragClip.width;
}

this acts sort of weird…