flash - Dragged object tweened back into original position in actionscript 3 -


i have object on stage can dragged. on release, snaps orginal position. want able tween original position smooth , not choppy. here code have 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 or tween position  blocksmallz.x = startposition.x; blocksmallz.y = startposition.y; startposition = null;  } 

you need code based tweening library. recommend learning gtween: http://www.gskinner.com/libraries/gtween/

after importing libary, @ point go:

blocksmallz.x = startposition.x; blocksmallz.y = startposition.y; 

you instead insert line of code tween back. simple as:

gtweener.addtween (blocksmallz, 1, { x:startposition.x, y:startposition.y } );


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -