Okay I’m trying to write a prototype function that I constructed off of a tutorial from bit101.com. Its a basic motion script for elasticity. The code when exported in Flash Player 6 works great. Now, when I publish this code in Player 7 everything breaks. I’ve narrowed the problem down to when velX and velY are calculated, it returns NaN. Anyone know why this is and/or have a fix so it will work in both versions?
Here’s my code:
MovieClip.prototype.bounceTo = function (endX, endY, inertia, k, interval) {
clearInterval(bounceInterval);
bounceInterval = setInterval(bounceAction, interval, this, endX, endY, inertia, k);
}
function bounceAction (clip, targX, targY, inertia, k) {
accelX = (targX-clip._x)*k
velX += accelX;
velX *= inertia;
accelY = (targY-clip._y)*k;
velY += accelY;
velY *= inertia;
clip._x += velX;
clip._y += velY;
//trace(accelX);
if (Math.abs(accelX) < .005 && Math.abs(accelY) < .005) {
trace("!ending bounceTo!");
clearInterval(bounceInterval);
}
}