dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] Drag and Drop is possible???

  1. #1
    Junior Member
    Join Date
    Aug 2009
    Posts
    17

    resolved [RESOLVED] Drag and Drop is possible???

    I can not do a drag and drop the labels of the buttons to text boxes. I needed that the value of the button (name) could be completed in the text box when I drag and drop the button in the text box.
    Attached Files Attached Files

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Here's an example, I don't think you can drag a button so I used movieclips.
    Attached Files Attached Files

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Basically you use event listeners (the AS3 way) and then use hitTest to if it's dropped on txtfield then set the text.

    PHP Code:
    mc1.buttonMode=true;
    mc1.addEventListener(MouseEvent.MOUSE_DOWN,mdown);
    mc1.addEventListener(MouseEvent.MOUSE_UP,mup);

    mc2.addEventListener(MouseEvent.MOUSE_DOWN,mdown);
    mc2.addEventListener(MouseEvent.MOUSE_UP,mup);


    var 
    tempx:Number;
    var 
    tempy:Number;

    function 
    mdown(e:MouseEvent):void{
    tempx=e.currentTarget.x;
    tempy=e.currentTarget.y;
    e.currentTarget.startDrag();
    }

    function 
    mup(e:MouseEvent):void{
     
    obj=e.currentTarget;
     if (
    obj.hitTestObject(txt2)){
         
    txt2.text=obj.txt1.text;
         }
     
    obj.x=tempx;
     
    obj.y=tempy;
     
    obj.stopDrag();
     } 

  4. #4
    Junior Member
    Join Date
    Aug 2009
    Posts
    17
    Thank you very much for your help clarify my doubt. Really 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