A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Drag/drop - addChild problem

Hybrid View

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Unhappy Drag/drop - addChild problem

    Hi Flashkits!

    I'm trying to drag multiple MC's around with the normal metod:

    function mouseDownHandler(event:MouseEvent):void {
    event.target.startDrag(false);
    }


    function mouseUpHandler(event:MouseEvent):void {
    event.target.stopDrag();

    }

    But it only works on the MC first added (addChild).. Actually it feels like there's pice of glass between the first added MC's and the ones "underneath".

    I really hope someone can lead me in the right direction - i has been bugging me for hours now..

  2. #2
    Junior Member
    Join Date
    Oct 2008
    Posts
    26
    i am not sure if this is correct but...

    event.target.startDrag(); is a reference to the original displayobject which dispatched the event. this means that when you invoke the startDrag() method it will only drag the displayobject that called the event handler.

    i would attempt to add all of the objects you wish to drag to a single container and call startDrag on that container.

    Code:
    var containerMC:MovieClip
    var mc1:MovieClip
    var mc2:MovieClip
    
    containerMC.addChild(mc1)
    containerMC.addChild(mc2)
    
    containerMC.addEventListener(e:mousevent){
      containerMC.startDrag();
    }
    or if you already have all your movieclips in a container and you want to drag that entire container you can use this.startDrag();
    //peace.*

  3. #3
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Use always
    event.currentTarget.startDrag();
    It will only drag the target currently touched by the mouse. Using "target" allows bubbling.
    - The right of the People to create Flash movies shall not be infringed. -

  4. #4
    Junior Member
    Join Date
    Feb 2009
    Posts
    4

    Thumbs up

    The problem was caused by caurina tweener on the MC's..

    Thanks for your help - i'm sure someone else can benefit from your answeres..

  5. #5
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Flashkit and their moderators are not liable for any third party problems .
    - The right of the People to create Flash movies shall not be infringed. -

Tags for this Thread

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