A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Drag and Drop - how to constrain?

  1. #1
    Confounded Flash User
    Join Date
    Apr 2001
    Location
    Chicago
    Posts
    39
    Hi all,

    I have a simple draggable movie clip. What I want to do is only allow the movie clip to be dragged into a certain area on the stage, and if it is not dragged into that area then it snaps back to its original position.

    Can anyone help with this? I am a beginner so please try and explain it well! Thanks so much!

    TOm

  2. #2
    Senior Member
    Join Date
    Apr 2000
    Location
    ATL - Georgia
    Posts
    226

    try this...

    on (press) {
    startDrag ("/drag", false, 105, 230, 430, 230);
    }
    on (release) {
    if (getProperty("/drag", _droptarget) eq "/drop") {
    tellTarget ("/feedback") {
    gotoAndStop ("correct");
    }
    } else {
    setProperty ("/drag", _x, 113);
    setProperty ("/drag", _y, 230);
    tellTarget ("/feedback") {
    gotoAndStop ("incorrect");
    }
    }
    stopDrag ();
    }

    **The top part constrains to an axis. the bottom after else tells the MC to spring back if not dropped in the correct place.

  3. #3
    Senior Member
    Join Date
    Apr 2000
    Location
    ATL - Georgia
    Posts
    226
    if you need more explaination, let me know.

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