actionscript-3drag-and-dropmouseeventonmouseup

After end of MouseMove or drag event menu keeping from release menu items


I am having a problem with draggable menu including menu button items. At the end of drag operation (when I lift my finger from the screen) a button sub item works because of its MOUSE_UP code.

I need drag end drop my menu. After drop menu button items listeners should start for release (MOUSE_UP). How can I separete them?

I read some similar messages but I couldnt solve my problem.

My code:

addEventListener(MouseEvent.MOUSE_MOVE, dragStart); 
addEventListener(MouseEvent.MOUSE_UP, dragStop); 
function dragStart(e:MouseEvent):void {
    e.currentTarget.startDrag(false,new Rectangle(0,0,500,0)); 
}
function dragStop(e:MouseEvent):void { 
    e.currentTarget.stopDrag(false,new Rectangle(0,0,500,0)); 
}

Thanks..

My sample file is here


Solution

  • update:
    I was getting it wrong. I'd suggest switching a flag in the parent clip when it is dragged and ignore MOUSE_UP events in children if it is true.

    In the parent:

    var dragging:Boolean = false;
    
    function dragStart(e:MouseEvent):void{
        e.currentTarget.startDrag(false,new Rectangle(0,0,500,0));
        dragging = true;
    }
    function dragStop(e:MouseEvent):void{
        e.currentTarget.stopDrag();
        removeEventListener(MouseEvent.MOUSE_MOVE, dragStart);
        dragging = false;
    }
    

    In subItem:

    function BTN(e:MouseEvent):void{
        if(!(parent as MovieClip).dragging){
            trace("I'm a button: "+this+" Did you hit me when you sliding?");
        }   
    }