Created
May 4, 2015 15:56
-
-
Save audinue/bd802e4c8e4ed6033396 to your computer and use it in GitHub Desktop.
Mouse Wheel Zoom
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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