0

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

  • Post your code please. – null Jul 28 '16 at 09:08
  • Thanks null; I added my code in my question message. – Erkan Çamyar Jul 28 '16 at 09:28
  • So your problem is that sub-items get a `MOUSE_UP` from parent menu? Or vice-versa? Or am I missing the point? – www0z0k Jul 28 '16 at 09:47
  • Yes. As you said www0z0k, all sub items are buttons having MOUSE_UP functions. Each button infact same mc but includes are different. 'this.addEventListener(MouseEvent.MOUSE_UP, BTN); function BTN(e:MouseEvent):void { var b=MovieClip(this.parent).parent.parent["Liste"+(root as MovieClip).ListeNo][int(this.name.split("BTN")[1])]; (root as MovieClip).sultan.eklenenNo=b; (root as MovieClip).BTNswitchCase(b); } ' – Erkan Çamyar Jul 28 '16 at 10:52
  • 2
    I think you're basically asking the same question as this one I answered a few days ago: http://stackoverflow.com/a/38531688/1457439 – BadFeelingAboutThis Jul 28 '16 at 16:42

1 Answers1

0

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?");
    }   
}
www0z0k
  • 4,444
  • 3
  • 27
  • 32
  • Thanks www0z0k, I ll research e.stopImmediatePropagation now. – Erkan Çamyar Jul 28 '16 at 14:06
  • Thats fine. It works. Thanks www0z0k. Thanks BadFeelingAboutThis too. I try to use e.stopImmediatePropagation() but I didnt achieve tis :( – Erkan Çamyar Jul 29 '16 at 08:52
  • Hi www0z0k, another problem exist now. My each touch on the screen only move function works. Sub item buttons dosnt work despite small touching on the mobile phone screen. – Erkan Çamyar Jul 29 '16 at 11:46
  • @ErkanÇamyar does it seem to happen because finger tap always produces a small move? – www0z0k Jul 29 '16 at 12:13
  • Yes you are right @www0z0k . Deffinetely small movement is the reason. – Erkan Çamyar Jul 29 '16 at 12:20
  • 1
    I solved small movement problem with a simple trick. I used a counter working during drag operation. When mouse up if counter is higher than a small value (limit value) dragging is equal to true. Otherwise false. Thanks @ www0z0k – Erkan Çamyar Jul 29 '16 at 15:04