| ||
Once again, its time to review the important formulas presented in this chapter.
Simple easing, long form:
var dx:Number = targetX - movieclip._x; var dy:Number = targetY - movieclip._y; vx = dx * easing; vy = dy * easing; movieclip._x += vx; movieclip._y += vy;
Simple easing, abbreviated form:
vx = (targetX - movieclip._x) * easing; vy = (targetY - movieclip._y) * easing; movieclip._x += vx; movieclip._y += vy;
Simple easing, short form:
movieclip._x += (targetX - movieclip._x) * easing; movieclip._y += (targetY - movieclip._y) * easing;
Simple spring, long form:
var ax:Number = (targetX - movieclip._x) * spring; var ay:Number = (targetY - movieclip._y) * spring; vx += ax; vy += ay; vx *= friction; vy *= friction; movieclip._x += vx; movieclip._y += vy;
Simple spring, abbreviated form:
vx += (targetX - movieclip._x) * spring; vy += (targetY - movieclip._y) * spring; vx *= friction; vy *= friction; movieclip._x += vx; movieclip._y += vy;
Simple spring, short form:
vx += (targetX - movieclip._x) * spring; vy += (targetY - movieclip._y) * spring; movieclip._x += (vx *= friction); movieclip._y += (vy *= friction);
Offset spring:
var dx:Number = movieclip._x - fixedX; var dy:Number = movieclip._y - fixedY; var angle:Number = Math.atan2(dy, dx); var targetX:Number = fixedX + Math.cos(angle) * springLength; var targetY:Number = fixedX + Math.sin(angle) * springLength; // spring to targetX, targetY as above
| ||