mercredi 30 septembre 2015

Dragged object tweened back into original position in actionscript 3

I have an object on my stage that can be dragged. On release, it snaps back into its orginal position. I want to be able to tween it back into its original position so that it will look smooth and not choppy. Here is the code that I have so far:

var startPosition:Point;

blockSmallz.addEventListener(MouseEvent.MOUSE_DOWN, dragz);
stage.addEventListener(MouseEvent.MOUSE_UP, dragStopz);

function dragz(e:Event):void {
blockSmallz.startDrag();
startPosition = new Point( blockSmallz.x, blockSmallz.y);
}

function dragStopz(e:Event):void {
blockSmallz.stopDrag();
//set back or tween position

blockSmallz.x = startPosition.x;
blockSmallz.y = startPosition.y;
startPosition = null;

}

Aucun commentaire:

Enregistrer un commentaire