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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -