A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Drag and drop

  1. #1
    Member
    Join Date
    Feb 2010
    Posts
    79

    Drag and drop

    Actionscript Code:
    myMovieClip.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
    myMovieClip.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
    myMovieClip2.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
    myMovieClip2.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
    function onStartDrag(evt:MouseEvent):void {
    evt.target.startDrag();
    }
    function onStopDrag(evt:MouseEvent):void {
    stopDrag();
    }
    stage.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);

    Every thing is working well... I have a doubt in last line...

    Actionscript Code:
    stage.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);

    I know why we are using this script here. And what is happening in output after adding this script.... But i need brief explanation... can u guys help me? pls....

  2. #2
    Senior Member
    Join Date
    Jan 2009
    Posts
    208
    You attach a listener to the stage if a mouse up happens out of the element you are dragging.

    You might also need MOUSE_LEAVE, or MOUSE_OUT if the drop happens out of the stage window.

  3. #3
    Member
    Join Date
    Feb 2010
    Posts
    79
    Quote Originally Posted by regbolD View Post
    You attach a listener to the stage if a mouse up happens out of the element you are dragging.

    You might also need MOUSE_LEAVE, or MOUSE_OUT if the drop happens out of the stage window.
    Thank you....

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