Skip to content

Instantly share code, notes, and snippets.

@mattlundstrom
Created June 15, 2012 19:06
Show Gist options
  • Save mattlundstrom/2938219 to your computer and use it in GitHub Desktop.
Save mattlundstrom/2938219 to your computer and use it in GitHub Desktop.
Flash Programmatic Easing
import flash.events.Event;
this.addEventListener(Event.ENTER_FRAME, loop);
var drag:Number = 10;
var mc:MovieClip = new MovieClip;
var gfx:Graphics = mc.graphics;
gfx.beginFill(0x000000);
gfx.drawCircle(0,0,10);
addChild(mc);
function loop(e:Event):void
{
var destinationX:Number = mouseX;
var destinationY:Number = mouseY;
var currentX:Number = mc.x;
var currentY:Number = mc.y;
mc.x += (destinationX - currentX) / drag;
mc.y += (destinationY - currentY) / drag;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment