Get Adobe Flash player

Posts Tagged ‘proximity’

AS3 DragObject – Dynamic Animation via Destination

Thursday, March 6th, 2008

I’ve been using this DragObject class for a while now. It was just a quick little MovieClip extension I threw together to give any MovieClip I had a destination x and y to automatically animate to. Simply explained, when the destination x and y are changed, the onEnterFrame function makes sure the clip animates to it. Since putting it together, I’ve been very fond of this sort of tweening concept. It allows for dynamic changing of properties without needing to worry about mid-animation changes; with only 1 property determining the destination value, your MovieClip will never get confused or lost as to which way it should be going.

One thing to note is that on the timeline I have set up a globalMouseUp function. This is necessary for implementation of the DragObject if your cursor is able to leave the object when dragging it.

Also added in some fun proximity checking. Source and Enjoy.

-Andrew