Search code examples
actionscript-3draggablebounds

AS3 libraries with a startDrag() equivalent that has non-rectangular boundaries (ie: circular)?


I'm just trying to avoid rolling my own dragging functionality. Does anyone know of any libraries out there that have a startDrag() equivalent where you can use, say, a circular radius for the drag bounds, rather than a rectangular box?


Solution

  • (For circular drag area) - What you need to do is:

    a) Mouse_down: Store start position. Start listening to Enter_frame.

    b) Enter_Frame: Check distance from mouse position of mouse to start pos (use pythagoras)

    c) only move your object if the distance is less than x

    d) Mouse_up: Stop listening to enterframe