|
-
Senior Member
Constrain Dragging
I have an object that needs to be dragged, but I need to constrain where it can be dragged to.
I need to only move on the X Axis - Left and Right,
And I need it to not be able to go past the right side of the stage, and then to not be able to go past an X value of 50.
Any ideas? Suggestions? Advice? Help? Thanks.
-
anyone else hear that?
ummm...just add in the startDrag constraints...
startDrag(target:Object, [lock:Boolean, left:Number, top:Number, right:Number, bottom:Number]) : Void
Hope that helps...
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
-
Senior Member
Thanks, but I get an argument mismatch error with that.
evt.target.startDrag(false, 50, 0, stage.stageWidth-50, stage.stageHeight);
that's my code. Any further ideas? Thanks.
-
anyone else hear that?
Are you using evt and target as your instance names to refer to the clip you want to drag?? Not sure why you would get an error...does the startDrag without the parameters work?
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
-
Senior Member
Yes, without the parameters it does work, yet if I add the parameters everything messes up.
I have that within a function called startDragFunc:
function startDragFunc(evt:Event):void {
evt.target.startDrag();
}
See anything wrong? Thanks again.
-
anyone else hear that?
Have you tried testing it with hard-coded values to see if it's the stage references causing the problem?
Try:
evt.target.startDrag(false, 50, 0, 150, 0);
I think it's Stage.width and Stage.height...try that too
Hope that helps...
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
-
Senior Member
No Luck, any more ideas? Thanks.
-
anyone else hear that?
Ah...try this...set a rectangle and set the bounds to that:
http://board.flashkit.com/board/showthread.php?t=755576
Hope that does it...
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
-
Senior Member
Thanks again, but still no luck, I tried the rectangle thing, and for some reason I can still drag it on the x and y axis. Any other ideas? Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|