Skip to main content
Participant
October 5, 2010
Question

making a draggable item, that can only drag on an axis.

  • October 5, 2010
  • 1 reply
  • 1025 views

Hi, thanks for your time.

What I want to create is a movie clip, that I can drag, but only on axis, such as up and down, but not left to right. For example, only on an X axis, but not on a Y axis.

The code i'm currently using to make the items draggable is:

pc.onPress=function(){

startDrag("pc",true,50,50,550,350);

removeMovieClip("cnt");

}

pc.onReleaseOutside=pc.onRelease=function(){

stopDrag();

}

"pc" is the instance name of the movie clip I want to drag.

"cnt" is a line that I've got drawn between the various draggable points I've created.

Please help! Thanks again for your time,

Rich

This topic has been closed for replies.

1 reply

Participating Frequently
October 5, 2010

Hi Rich,


startDrag's signature is


startDrag(target,[lock, left, top, right, bottom])

If you want to constrain the drag to horizontal only (left to right) make sure "top" and "bottom" values are the same.

If you want to constrain the drag to vertical only (top to bottom) make sure "left" and "right" values are the same.

In case this wasn't exactly what you were looking for, please elaborate on your query.

Cheers

--Vikas

Inspiring
October 5, 2010

Sorry, in AS3 startDrag second parameter is a Rectangle - not an Array.

.