# Make it stop!

**URL:** <https://forum.kirupa.com/t/make-it-stop/317081>\
**Category:** Uncategorized\
**Created:** [December 9, 2010, 8:01pm UTC](https://forum.kirupa.com/t/make-it-stop/317081 "2010-12-09T20:01:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Numinus](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Numinus](https://forum.kirupa.com/u/Numinus)\
**Post date:** [December 9, 2010, 8:01pm UTC](https://forum.kirupa.com/t/make-it-stop/317081/1 "2010-12-09T20:01:39Z")

</div>

ok. can anyone figure out how to make this MC stop dragging and, more importantly, stop the pathFinder function when the MC is dragged before 150 or after 600 on the x-axis. this is the last thing i need to figure out, and its driving me crazy. i’ve tried removeEventListeners everywhere, no luck.

any ideas!?!?

```auto
 
var whichSide;
var error; // max number of pixels out
var tolerence = 1; // max error
var xie; // current x approximation
var yie; // current y approximation
var yAbove = 0; // best Approximation above line
var yBelow = 400; // best Approximation below line
myInstance.buttonMode = true;
myInstance.addEventListener(MouseEvent.MOUSE_DOWN, dragging);
myInstance.addEventListener(MouseEvent.MOUSE_UP, drop);
 
function dragging (event:MouseEvent):void {
 var dragBounds:Rectangle = new Rectangle(150, 200, 600, 100);
    myInstance.startDrag(false, dragBounds);
 addEventListener(Event.ENTER_FRAME, pathFinder);
}
 
function drop (event:MouseEvent):void {
    myInstance.stopDrag();
 this.removeEventListener(Event.ENTER_FRAME, pathFinder);
 if (myInstance.x > 450){
  whichSide = "right";
 } else {
  whichSide = "left";
 }
 slideBack();
}
 
function pathFinder(event:Event) {
 xie = mouseX;
 yie = mouseY;
  do {
   if (hitGuide.hitTestPoint(xie, yie, true)){
    yBelow = yie
    yie = (yie + yAbove)/2;
   } else {
    yAbove = yie;
    yie = (yie + yBelow)/2;
   }
   
   error = yBelow - yAbove;
   
  } while (error > tolerence);
   yAbove = 0;
   yBelow = 400;
   myInstance.x = xie;
   myInstance.y = yie;
}

```
