dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: CLICK vs. MOUSE_UP

Hybrid View

  1. #1
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476

    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.CLICKpaper1func);
    paper1.addEventListener(MouseEvent.MOUSE_DOWNpaperDrag);
    paper1.addEventListener(MouseEvent.MOUSE_UPpaperStopDrag);
    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();


  2. #2
    :
    Join Date
    Dec 2002
    Posts
    3,518
    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();
    }

  3. #3
    Member Mofo SwirlyKing's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    476
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center