Pages

Wednesday, May 2, 2012

How to use mouse wheel for Zoom IN Zoom OUT in Actionscript3.0





Here we look at Mouse Scroll Zoom In and Zoom Out in AS3.

/** add Mouse Wheel event for stage **/

stage.addEventListener(MouseEvent.MOUSE_WHEEL, Zoom);

/** ma_mc is the mountain image MovieClip **/
function Zoom(e:MouseEvent):void
{       
var mod:Number = 20;
ma_mc.scaleX += e.delta / mod;
        ma_mc.scaleY += e.delta / mod;
        ma_mc.x = ((2 * mouseX) - (2 * (e.localX * ma_mc.scaleX))) / 2;
ma_mc.y = ((2 * mouseY) - (2 * (e.localY * ma_mc.scaleY))) / 2;
}


...CHeeRS...





SourceFile

0 comments:

Post a Comment