jrojas Posted November 22, 2010 Share Posted November 22, 2010 I am trying to drag and drop a very large movie clip (1600 X 1000), and would like to use a tween to make the dragging and dropping smooth. holder_mc.addEventListener(MouseEvent.MOUSE_DOWN, PickImage); stage.addEventListener(MouseEvent.MOUSE_UP, DropImage); function PickImage (e:MouseEvent):void { holder_mc.startDrag(); TweenMax.to(holder_mc, .2, {x:mouseX, y:mouseY, ease:Sine.easeInOut}); } function DropImage(e:MouseEvent):void { holder_mc.stopDrag(); TweenMax.to(holder_mc, 4, {x:mouseX, y:mouseY, ease:Sine.easeInOut}); } My method is all wrong. The movie clip want to snap to its registration point rather than jus tpick up where it was clicked. Maybe it should follow the mouse after a click instead? And how would I tween it tom make it nice? Im trying to achieve an effect similar to this -- http://journey-to-zero.com/#/RSW thanks!!! Link to comment Share on other sites More sharing options...
Carl Posted November 22, 2010 Share Posted November 22, 2010 hello jrojas, I don't think there is an out of the box greensock solution for this. Your example shows that the image is not dropped but thrown. What is happening theoretically is that the speed of your mouse along the x and y axis is constantly being determined, when you release the mouse that speed is used used to propel the image in the proper direction and friction slows it down. a partial example of the code involved is available here: http://efreedom.com/Question/1-1941989/ ... op-Inertia the physics2d plugin might come in handy. its a club greensock benefit and you can see its power in the plugin explorer: http://www.greensock.com/tweenlite/ regardless of the solution you use, you are going to have to determine the direction and speed of the mouse movement. to determine how hard the object is thrown and in which direction. This is often achieved by continuously sampling the current mouse position (on an EnterFrame or MouseMove event) compared to the previous mouse position (both mouseY mouseX). Try googling: drag and throw smooth drag drag and drop easing drag and drop inertia unfortunately it isn't a quick answer. Carl Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now