
Код:
function test(target1, target2) {
var xm = target2._x;
var ym = target2._y;
target1.destrot = (Math.atan((ym-target1._y)/(xm-target1._x))*180)/Math.PI;
if (xm<target1._x) {
target1.destrot = target1.destrot+180;
}
target1.onEnterFrame = function () {
trace(this.destrot);
this._rotation += (this.destrot-this._rotation)/4;
};
}