Speed in relation to distance

Hi,

Is there a way i can make a movieclip speed up or slow down according to the distance between the mouse and the movieclip? I’ve made a friction effect for a movie clip (script 1) and i have a script to work out the distance between the mouse and an object (script 2) but i cant seem to integrate the two…anyone done this? I dont understand the distance script 100%, i pretty much got it from a book i own…any help on this would be great…

script 1 - friction.


xmov = 50;
decay = .99;
this.onEnterFrame = function() {
    if (_root._xmouse > Stage.width/2) {
        this.cam.x += xmov;
    }
}

script 2 - distance


var mc1 = largest_mc;
onEnterFrame = function() {
var dx:Number = mc1._x - _xmouse;
var dy:Number = mc1._y - _ymouse;
var dist:Number = Math.round(Math.sqrt((dx*dx) + (dy*dy)));
trace(dist);

}

Thanks…