AS3 Easy Mouse Panning


/ Published in: ActionScript 3
Save to your folder(s)

A simple demo that shows how to pan from one side of an object to another dynamically in actionscript 3.

demo at: http://www.adamcoulombe.info/lab/as3/sliderbox.html


Copy this code and paste it in your HTML
  1. //A simple demo that shows how to pan from one side of an object to another dynamically in actionscript 3.
  2.  
  3. //demo at: http://www.adamcoulombe.info/lab/as3/sliderbox.html
  4.  
  5. import fl.transitions.Tween;
  6. import fl.motion.easing.*;
  7. import fl.transitions.TweenEvent;
  8.  
  9. var sliderBoxTween:Tween
  10.  
  11. stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoved)
  12.  
  13. function mouseMoved(e){
  14. var xPercent = mouseX / stage.stageWidth;
  15. var newXPos = (stage.stageWidth - sliderBox.width) * xPercent;
  16. sliderBoxTween = new Tween(sliderBox, "x", Circular.easeOut, sliderBox.x, newXPos, 1, true);
  17. }

URL: http://www.adamcoulombe.info/lab/as3/sliderbox.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.