Отслеживайте цель, о которой вы беспокоитесь, и слушайте только события непосредственно с нее. Итак, в вашей функции mousemove проверьте e.target == ваш объект. В этом случае приложение. Вы получите случайные события, всплывающие из подкомпонентов.
public static function smoothDrag(pressEvent:MouseEvent, dragTarget:DisplayObject = null, done:Function=null, move:Function = null, parent:DisplayObject = null):void {
var target:DisplayObject = dragTarget;
parent = parent || target.parent;
var eventParent:EventDispatcher = target.stage || parent;
var moveFunc:Function = move;
var doneFunc:Function = done;
var startPoint:Point = MouseHelpers.pointTo(pressEvent.localX, pressEvent.localY, pressEvent.target as DisplayObject, parent);
startPoint.x -= target.x
startPoint.y -= target.y;
var setPosition:Function = function(e:MouseEvent):void
{
e.stopImmediatePropagation();
var p:Point = MouseHelpers.pointTo(e.localX,e.localY, e.target as DisplayObject, parent);
target.x = p.x - startPoint.x;
target.y = p.y - startPoint.y;
if (moveFunc != null) {
moveFunc();
}
}
var stopMove:Function = function(e:MouseEvent):void {
e.stopImmediatePropagation();
eventParent.removeEventListener(MouseEvent.MOUSE_MOVE, setPosition, true);
eventParent.removeEventListener(MouseEvent.MOUSE_UP, stopMove, true);
eventParent.removeEventListener(MouseEvent.ROLL_OVER, EventHelpers.stop, true);
eventParent.removeEventListener(MouseEvent.MOUSE_OVER, EventHelpers.stop, true);
if (doneFunc != null) {
doneFunc(e);
}
}
eventParent.addEventListener(MouseEvent.ROLL_OVER, EventHelpers.stop, true, 0, true);
eventParent.addEventListener(MouseEvent.MOUSE_OVER, EventHelpers.stop, true, 0, true);
eventParent.addEventListener(MouseEvent.MOUSE_MOVE, setPosition, true, 0, true);
eventParent.addEventListener(MouseEvent.MOUSE_UP, stopMove, true, 0, true);
}
/**
* Translate a point from one object's reference into another. Best used when you have a descendant object x/y and you
* want to get that position relative to an ancestor. Uses the localToGlobal/globalToLocal style.
**/
public static function pointTo(fromX:Number, fromY:Number, src:DisplayObject, dest:DisplayObject):Point {
var p:Point = new Point(fromX, fromY);
if(src != dest) {
p = src.localToGlobal(p);
p = dest.globalToLocal(p);
}
return p;
}