There are a lot of ActionScript formulas that are perfectly at home in everyday web development. Today’s frameworks are such that you wouldn’t normally give such formulas a second thought but since ActionScript and JavaScript are so similar its trivial to port (“port” is used generously here) one to the other as long as there are analogous objects, etc. I’m going to run through some of them here for fun.

Linear Animation Formulas

Here are two linear AS3 animation formulas. This first one contains an elastic coefficient (spring) that gets applied to the animated HTML element once it hits its end point.

...
vx += (targetX – sprite.x) * spring;
vy += (targetY – sprite.y) * spring;
sprite.x += (vx *= friction);
sprite.y += (vy *= friction);
...

This next one is a formula for linear animation that includes easing (ease out).

...
sprite.x += (targetX – sprite.x) * easing;
sprite.y += (targetY – sprite.y) * easing;
...

Here’s my first take at replicating both of the above in JavaScript.

… (more to come)…