Return to Snippet

Revision: 57010
at May 3, 2012 22:33 by hejaaa


Initial Code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
				creationComplete="init(event)"
				width="634" height="440" minWidth="955" minHeight="600" layout="absolute">
	<mx:Script>
		<![CDATA[
			import mx.events.FlexEvent;

			import com.greensock.TweenMax;
			import com.greensock.plugins.TransformAroundPointPlugin;
			import com.greensock.plugins.TweenPlugin;
			
			private var scaling:Number = 1;
			
			protected function init(event:FlexEvent):void
			{
				TweenPlugin.activate([TransformAroundPointPlugin]);
				img.addEventListener(MouseEvent.MOUSE_WHEEL, zoomingEvent);
			}
			
			protected function zoomingEvent(e:MouseEvent):void
			{
				scaling += e.delta * .05;
				if(scaling > 1)
					scaling = 1;
				if(scaling < .25)
					scaling = .25;
				
				trace("scaleBook", img.y, img.y);
				
				TweenMax.to(img, .5, {transformAroundPoint:{point:new Point(img.mouseX, img.mouseY), pointIsLocal:true, scale: scaling}});
			}
		]]>
	</mx:Script>
	
	<mx:Canvas x="0" y="0" width="634" height="440" verticalScrollPolicy="off" horizontalScrollPolicy="off">
		<mx:Image id="img" x="-40" y="-18" width="2048" height="1356" source="@Embed(source='assets/DSC_1414-2048.jpg')"/>
	</mx:Canvas>
</mx:Application>

Initial URL
http://shakezooming.bozon.sk/

Initial Description
not work correktly

Initial Title
mouse wheel zooming (shaking-shocking)

Initial Tags

                                

Initial Language
ActionScript 3