Skip to content

Instantly share code, notes, and snippets.

@audinue
Created May 4, 2015 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save audinue/bd802e4c8e4ed6033396 to your computer and use it in GitHub Desktop.
Save audinue/bd802e4c8e4ed6033396 to your computer and use it in GitHub Desktop.
Mouse Wheel Zoom
import flash.events.MouseEvent;
stage.addEventListener(MouseEvent.MOUSE_WHEEL, mouseWheel);
var scale:Number = 1;
function mouseWheel(e:MouseEvent):void {
scale = e.delta > 0 ? scale + .5:scale - .5;
image.scaleX = image.scaleY = scale;
image.x = mouseX - e.localX * image.scaleX;
image.y = mouseY - e.localY * image.scaleY;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment