Quantunet.com

My Account

Joins Us
Flash 8 Actionscript 2.0 Knowledgebase
2D Elastic Motion + Friction & Inertial Based Dampening  

Download .fla

Actionscript

var k:Number = 0.1;
var f:Number = 0.85;
var I:Number = 2;
var vx:Number = 0;
var vy:Number = 0;

onEnterFrame = function() {

distx = (_xmouse - ball_mc._x);
disty = (_ymouse - ball_mc._y);

vx = vx*f + distx*k*(1/I);
vy = vy*f + disty*k*(1/I);

ball_mc._x += vx;
ball_mc._y += vy;

clear();
lineStyle(1,0x999999,100);
moveTo(ball_mc._x,ball_mc._y );
lineTo(_xmouse,_ymouse);
updateAfterEvent();
};





© 2008 Quantunet LLC All Rights Reserved | Intellectual Property | Terms of Use | Privacy
Home | About Quantunet | FAQ's | Contact Us