views:

33

answers:

2

There is a mouseUpEvent listener attached to the stage in the main class, while dragging the movieClip the mouseUpEvent doesnot trigger the handler and the movieClip gets sticks to the mouse. While the item is being dragged and the mouse is moved away from the movieClip i.e somewhere not on the item but on the stage the mouseUp is detected.

Edit: Here is the scenario I am using a static (Singleton) class as a movieClip as a "DragManager". Whenever a movieClip has to be dragged it is passed to the DragManager and is added as a child, when a mouseUp from stage is detected another static function of dragManager is called to stop the drag and put the movieClip on the appropriate layer. Here is the static function in the DragManager which is called on MouseDown from variouslayers.

public static function startDragMethod(item:Item):void
{
instance.addChild(item);    //This is the instance of the DragManager
var boundArea:Rectangle = new Rectangle(0,0,610,760);
item.startDrag(false,boundArea);
}

In the constructor of the main class I add the eventHandler for the MouseUpEvent

this.addEventListener(MouseEvent.MOUSE_UP,stageMouseUpHandler);

The MouseUpHandler in the main class

private function stageMouseUpHandler(event:MouseEvent):void
{
DragManager.itemMouseUpHandler(event);
}

If there is something wrong with technique please guide me, my goal is to implement drag drop between various layers and with as less coupling as possible.

A: 

Please show your code, it's hard to understand your problem without it.

Dmitri Semenov
A: 

Well there are many ways to get the task done. Put some condition at your static listener function or when the object is dragged. like

public static function startDragMethod(item:Item):void { instance.addChild(item); //This is the instance of the DragManager var boundArea:Rectangle = new Rectangle(0,0,610,760); item.startDrag(false,boundArea); check = true; }

private function stageMouseUpHandler(event:MouseEvent):void { if(check==true) { DragManager.itemMouseUpHandler(event); check = false; } }

Muhammad Irfan