Alright so I have this code for throwing/dragging for movieclips. All i want is for the mcs not to spin as much. I realize this is some crazy long code that I don’t really understand so if no one can do it…so be it
here it is in action www.radioactivechimp.com/ChimpPages/Newsite.htm
MovieClip.prototype.declareToRotate = function()
{
this.mode = "release";
this.x = this._x;
this.y = this._y;
this.r = 0;
this.draw();
topDepth = 500;
this.onPress = function()
{
topDepth = topDepth + 2;
this.swapDepths(topDepth);
this.moveControl("click");
}
this.onRelease = this.onReleaseOutside = function()
{
this.moveControl("release");
}
}
MovieClip.prototype.moveControl = function (option)
{
var _l3 = _global;
{
switch (option)
{
case "click":
{
this.weight = _l3.weight_small;
this.inertia = _l3.inertia_small;
this.b = _l3.b_small;
this.onEnterFrame = this.moveLoop;
this.mode = "drag";
this.first_action = true;
break;
}
case "release":
{
if (this.mode != "focus")
{
this.mode = "release";
this.first_action = true;
}
break;
}
case "rotate_align":
{
this.mode = "focus";
this.tox = this.x;
this.toy = this.y;
this.r = (this.r + 360000) % 360;
this.tor = (-this._parent._rotation + 360000) % 360;
this.onEnterFrame = this.moveLoop;
break;
}
case "reset":
{
this.x = scWidth / 2 - scWidth / 2 * randx * bunpu_x;
this.y = scHeight / 2 - scHeight / 2 * randy * bunpu_y;
this.r = Math.round(Math.random() * 360);
this.moveControl("stop");
this.draw();
break;
}
}
}
};
MovieClip.prototype.moveLoop = function ()
{
switch (this.mode)
{
case "drag":
{
if (this.first_action)
{
this.first_action = false;
this.mx = this._parent._xmouse;
this.my = this._parent._ymouse;
this.dmx = 0;
this.dmy = 0;
}
else
{
this.mx = this._parent._xmouse;
this.my = this._parent._ymouse;
this.dmx = this.mx - this.mx0;
this.dmy = this.my - this.my0;
}
this.mx0 = this.mx;
this.my0 = this.my;
var fx = (this.dmx - this.vx) * this.weight;
var fy = (this.dmy - this.vy) * this.weight;
var _l3 = this.mx - this.x;
var _l2 = this.my - this.y;
if (fx == 0)
{
var mlength = _l3;
var mforce = fy;
var torque = mforce * mlength;
}
else if (fy == 0)
{
var mlength = _l2;
var mforce = fx;
var torque = -mforce * mlength;
}
else
{
var k = fy / fx;
var kx = (-k * k * _l3 + k * _l2) / (-k * k - 1);
var ky = k * (kx - _l3) + _l2;
var mlength = Math.sqrt(kx * kx + ky * ky);
var mforce = Math.sqrt(fx * fx + fy * fy);
if (fx * ky > 0)
{
var torque = -mforce * mlength;
}
else
{
var torque = mforce * mlength;
}
}
if (this.rotateMode == "force_to_0")
{
torque = 0;
}
this.vx = this.dmx;
this.vy = this.dmy;
this.x = this.x + this.vx;
this.y = this.y + this.vy;
this.vr = this.vr - torque / this.inertia;
_l3 = this.mx - this.x;
_l2 = this.my - this.y;
var cos = Math.cos(this.vr / 180 * 3.141593);
var sin = Math.sin(this.vr / 180 * 3.141593);
this.addx = _l3 * cos + _l2 * sin - _l3;
this.addy = -_l3 * sin + _l2 * cos - _l2;
this.x = this.x - this.addx;
this.y = this.y - this.addy;
this.r = this.r - this.vr;
this.vx = this.vx / this.b;
this.vy = this.vy / this.b;
this.vr = this.vr / this.b;
break;
}
case "release":
{
if (this.first_action)
{
this.first_action = false;
this.vx = (this.vx - this.addx) * speed;
this.vy = (this.vy - this.addy) * speed;
this.addx = 0;
this.addy = 0;
}
this.x = this.x + this.vx;
this.y = this.y + this.vy;
this.r = this.r - this.vr;
this.vx = this.vx / this.b;
this.vy = this.vy / this.b;
this.vr = this.vr / this.b;
break;
}
case "focus":
{
if (this.first_action)
{
this.first_action = false;
}
this.vx = (this.vx + (this.tox - this.x) / backA) / backB;
this.vy = (this.vy + (this.toy - this.y) / backA) / backB;
this.vr = (this.vr - (this.tor - this.r) / backRa) / backRb;
this.x = this.x + this.vx;
this.y = this.y + this.vy;
this.r = this.r - this.vr;
break;
}
}
this.checkScreenArea();
this.draw();
};
MovieClip.prototype.checkScreenArea = function ()
{
if (this.x < scMargin || this.x > scWidth - scMargin)
{
if (this.vx != undefined)
{
this.vx = -this.vx;
this.x = this.x + this.vx;
}
if (this.x < scWidth ){this.x = Math.max(this.x, scMargin);}
else{this.x = Math.min(this.x, scWidth - scMargin);}
this.draw();
}
if (this.y < scMargin || this.y > scHeight - scMargin)
{
if (this.vy != undefined)
{
this.vy = -this.vy;
this.y = this.y + this.vy;
}
if (this.y < scMargin){this.y = Math.max(this.y, scMargin);}
else{this.y = Math.min(this.y, scHeight - scMargin);}
this.draw();
}
};
MovieClip.prototype.draw = function ()
{
this._x = this.x;
this._y = this.y;
this._rotation = this.r;
};
_global.speed = .4;
_global.scMargin = 1;
_global.scwidth = 800;
_global.scheight = 600;
_global.b_small = 1.100000;
_global.b_large = 1.150000;
_global.backA = 2;
_global.backB = 2.500000;
_global.backRa = 2;
_global.backRb = 2.500000;
_global.weight_small = 3;
_global.inertia_small = 300;
_global.weight_large = 4;
_global.inertia_large = 500;
_global.gosa = 0.300000;
_global.firstClick = true;
//use the declareToRotate() prototype on mc's to get the rotate effect (like below)
News.declareToRotate();
Contact.declareToRotate();
About.declareToRotate();