Posted By

hejaaa on 05/03/12


Tagged

wheel zoom


Versions (?)

mouse wheel zooming (shaking-shocking)


 / Published in: ActionScript 3
 

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

not work correktly

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3. creationComplete="init(event)"
  4. width="634" height="440" minWidth="955" minHeight="600" layout="absolute">
  5. <mx:Script>
  6. <![CDATA[
  7. import mx.events.FlexEvent;
  8.  
  9. import com.greensock.TweenMax;
  10. import com.greensock.plugins.TransformAroundPointPlugin;
  11. import com.greensock.plugins.TweenPlugin;
  12.  
  13. private var scaling:Number = 1;
  14.  
  15. protected function init(event:FlexEvent):void
  16. {
  17. TweenPlugin.activate([TransformAroundPointPlugin]);
  18. img.addEventListener(MouseEvent.MOUSE_WHEEL, zoomingEvent);
  19. }
  20.  
  21. protected function zoomingEvent(e:MouseEvent):void
  22. {
  23. scaling += e.delta * .05;
  24. if(scaling > 1)
  25. scaling = 1;
  26. if(scaling < .25)
  27. scaling = .25;
  28.  
  29. trace("scaleBook", img.y, img.y);
  30.  
  31. TweenMax.to(img, .5, {transformAroundPoint:{point:new Point(img.mouseX, img.mouseY), pointIsLocal:true, scale: scaling}});
  32. }
  33. ]]>
  34. </mx:Script>
  35.  
  36. <mx:Canvas x="0" y="0" width="634" height="440" verticalScrollPolicy="off" horizontalScrollPolicy="off">
  37. <mx:Image id="img" x="-40" y="-18" width="2048" height="1356" source="@Embed(source='assets/DSC_1414-2048.jpg')"/>
  38. </mx:Canvas>
  39. </mx:Application>

Report this snippet  

You need to login to post a comment.