# Setting Drag Boundaries

**URL:** <https://forum.kirupa.com/t/setting-drag-boundaries/300662>\
**Category:** flash\
**Created:** [November 25, 2009, 8:11am UTC](https://forum.kirupa.com/t/setting-drag-boundaries/300662 "2009-11-25T08:11:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![romit\_2034](https://avatars.discourse-cdn.com/v4/letter/r/ed655f/32.png) [@romit\_2034](https://forum.kirupa.com/u/romit_2034)\
**Post date:** [November 25, 2009, 8:11am UTC](https://forum.kirupa.com/t/setting-drag-boundaries/300662/1 "2009-11-25T08:11:26Z")

</div>

For a project I am working on, the user can see sections of the website by dragging around horizontally or vertically on the screen. I have set up a dragging function for that. I am having trouble setting the boundaries however. When I reach the limit I have set for the dragging, the movieClips inside the movieClip I am dragging jump for half a second. The whole thing looks really bad. This is my code for dragging

```auto

private function dragIt(e:MouseEvent):void
        {
            difX = xPos - stageRef.mouseX;
            difY = yPos - stageRef.mouseY;
            
            if((target.x)-(difX)/3>1200)
            {
                target.x = 1200;
            }
            if((target.x)-(difX)/3<-1500)
            {
                target.x = -1500;
                
            }
            if((target.y)-(difY)/3>1000)
            {
                target.y = 1000;
                
            }
            if((target.y)-(difY)/3<-1000)
            {
                target.y = -1000;
            }
            if ((target.y)-(difY)/3>-1000 && (target.x)-(difX)/3<1200 && (target.x)-(difX)/3>-1500 && (target.y)-(difY)/3<1000)
            {
                TweenLite.to(target, 0.5, {x:(target.x)-(difX)/3,y:(target.y)-(difY)/3});    
            }
            
            e.updateAfterEvent();
        }

```

I am setting the limits here. But can’t get rid of the jump. How, do I make this smooth. Please help.
