Return to Snippet

Revision: 27898
at June 26, 2010 04:46 by adamcoulombe


Initial Code
//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

import fl.transitions.Tween;
import fl.motion.easing.*;
import fl.transitions.TweenEvent;

var sliderBoxTween:Tween

stage.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoved)

function mouseMoved(e){
	var xPercent = mouseX / stage.stageWidth;
	var newXPos = (stage.stageWidth - sliderBox.width) * xPercent;
	sliderBoxTween = new Tween(sliderBox, "x", Circular.easeOut, sliderBox.x, newXPos, 1, true);
}

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

Initial Description
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

Initial Title
AS3 Easy Mouse Panning

Initial Tags
actionscript, flash

Initial Language
ActionScript 3