A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: I can DRAG, but it wont DROP

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

    I can DRAG, but it wont DROP

    Hello Friends,
    Please help! i have written this AS3 code, and i am able to click and drag my movie clips, but then i can't drop them. they stay stuck to my cursor. Can you help??? It is a Mr. Potato Head drag and drop game/activity. If the code looks correct, what else could I have done to make this not work correctly? Could it have to do with some movie clip setting or something?? Please help! See code below:

    ________________________

    import flash.display.DisplayObject;

    left_arm.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    left_arm.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    right_arm.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    right_arm.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    left_leg.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    left_leg.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    right_leg.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    right_leg.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    eyes.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    eyes.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    mouth.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    mouth.addEventListener(MouseEvent.MOUSE_UP, dropIt);
    hat.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    hat.addEventListener(MouseEvent.MOUSE_UP, dropIt);

    function pickUp(event:MouseEvent):void {
    event.target.startDrag(true);

    }

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


    left_arm.buttonMode = true;
    right_arm.buttonMode = true;
    left_leg.buttonMode = true;
    right_leg.buttonMode = true;
    eyes.buttonMode = true;
    mouth.buttonMode = true;
    hat.buttonMode = true;

    ________________________

  2. #2
    Senior Member
    Join Date
    Feb 2006
    Location
    Düsseldorf, Germany
    Posts
    142
    hi, please use

    instead of
    Actionscript Code:
    event.target.startDrag(true);

    Just
    Actionscript Code:
    event.target.startDrag();

    see the diference in the docs: http://goo.gl/xi9ap
    --
    there is a place for those who dare to dream...

    Flash Developer
    VISTAPARK GMBH
    BÄRENSTRASSE 11-13
    D-42117 WUPPERTAL

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