# Flash Drag and Limit

**URL:** <https://forum.kirupa.com/t/flash-drag-and-limit/277441>\
**Category:** Uncategorized\
**Created:** [December 12, 2008, 1:04am UTC](https://forum.kirupa.com/t/flash-drag-and-limit/277441 "2008-12-12T01:04:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![udtrack](https://avatars.discourse-cdn.com/v4/letter/u/b782af/32.png) [@udtrack](https://forum.kirupa.com/u/udtrack)\
**Post date:** [December 12, 2008, 1:04am UTC](https://forum.kirupa.com/t/flash-drag-and-limit/277441/1 "2008-12-12T01:04:23Z")

</div>

I need some help with coding to drag an MC across the stage but limit it from going off the stage. I was able to limit it so it only moves along the x-axis, but I need the mc to stop when it gets to the end. I also am not sure of how I would drag or scroll around the stage once I have zoomed in. As you can see, the limit I set on the y-axis has not prevented me from going anywhere once I am zoomed in. And also, if anyone knows how to stop the mc from jumping when you drag it, that would be great too.

Here’s the code I used to limit the y-axis movement:

wall\_mc.onPress = function() {  
var dragging = false;  
this.onEnterFrame = function() {  
//stop dragging move mc to limit and drag again  
if ((wall\_mc.limit2.\_y+wall\_mc.\_y)\<=400) {  
//botomm  
stopDrag();  
wall\_mc.\_y = 400-wall\_mc.limit2.\_y;  
startDrag(this);  
}  
if ((wall\_mc.limit1.\_y+wall\_mc.\_y)\>=0) {  
// superior  
stopDrag();  
wall\_mc.\_y = 0;  
startDrag(this);  
}
