I am calculating mouse velocity, but every now and then you get a 0 for
velocity eventhough its not 0 (setInterval prob I suspect).  Any better
approach?

var MouseX;
var MouseY;

function determineVelocity():Void
{
   MouseX = _root._xmouse
   MouseY = _root._ymouse
   setTimeout( calc, 9 );
};

setInterval( determineVelocity, 20 );

function calc():Void
{
   var newMouseX:Number = _root._xmouse;
   var newMouseY:Number = _root._ymouse;

   var deltaX = Math.abs(MouseX - newMouseX)
   deltaY = Math.abs(MouseY - newMouseY)
   dist = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY))
   velocity = dist*31; // 31 = fps
   trace( velocity );
};
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to