Author Topic: Drag Bounds  (Read 105 times)

Wael Jammal   «   on: May 14, 2012, 04:37:02 PM »
Hi,

I'm trying to implement dragging using startDrag/stopDrag but I need to constrict the axis so it only drags on one of the axis, is this possible? I cant seem to get it working, I tried checking the X position against a starting value for instance and forcing it back if it changes but that makes no difference.

Thanks

Wael Jammal   «   Reply #1 on: May 14, 2012, 04:42:03 PM »
Forgot to also ask if there is a way to turn off the rotation when it's dragging.

Thanks again

Ivan Vodopiviz   «   Reply #2 on: May 15, 2012, 11:53:58 AM »
Hi,

Yes, it is possible. All you have to do is to listen for the drawgExit event and then you can do whatever you want with your dragging. Something like this:

mesh.addEventListener( "exitDrag", exitDragEvent );

private function exitDragEvent( e:Event ):void
{
    // this will force your mesh to remain at y = 10, but will allow it to be dragged on x
    e.target.y = 10;
}

With regards to your second question... I'm not sure what rotation you want to prevent. startDrag() doesn't rotate objects...

Cheers,

Ivan Vodopiviz   «   Reply #3 on: May 15, 2012, 11:57:25 AM »
Of course, it isn't "drawgExit", it's "exitDrag". Just to clarify :P