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!?!?
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;
}