-
Member Mofo
CLICK vs. MOUSE_UP
I have these papers I want to drag around and then fire a function when I CLICK, not when I MOUSE_UP. However, the CLICK function fires even on MOUSE_UP after dragging. I can't tell what I'm doing wrong. Is it even possible?
PHP Code:
paper1.addEventListener(MouseEvent.CLICK, paper1func);
paper1.addEventListener(MouseEvent.MOUSE_DOWN, paperDrag);
paper1.addEventListener(MouseEvent.MOUSE_UP, paperStopDrag);
paper1.buttonMode = true;
function paper1func(e:MouseEvent):void {
trace("paper1");
}
function paperDrag(e:MouseEvent):void {
this.setChildIndex(this.getChildByName(e.target.name), this.numChildren-1);
var p:Object = this.getChildByName(e.target.name);
p.startDrag();
}
function paperStopDrag(e:MouseEvent):void {
stopDrag();
}
-
To be able to drag or click...
Code:
paper1.addEventListener(MouseEvent.MOUSE_DOWN, paperDrag);
paper1.addEventListener(MouseEvent.MOUSE_UP, paperStopDrag);
paper1.buttonMode=true;
function paper1func(e:MouseEvent):void {
e.currentTarget.removeEventListener(MouseEvent.MOUSE_MOVE, doPaperMove);
trace(e.currentTarget.name);
}
function paperDrag(e:MouseEvent):void {
this.setChildIndex(DisplayObject(e.currentTarget), this.numChildren-1);
e.currentTarget.addEventListener(MouseEvent.MOUSE_MOVE, doPaperMove);
e.currentTarget.addEventListener(MouseEvent.CLICK, paper1func);
}
function doPaperMove(e:MouseEvent):void {
e.currentTarget.startDrag();
e.currentTarget.removeEventListener(MouseEvent.CLICK, paper1func)
e.currentTarget.removeEventListener(MouseEvent.MOUSE_MOVE, doPaperMove);
}
function paperStopDrag(e:MouseEvent):void {
stopDrag();
}
-
Member Mofo
Thanks DawsonK that worked! Seems like a lot of workaround for something that feels like it should be more intuitive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|