Drag and drop with collision detection

Here is a screenshot of the draggable movieclips:
draggable movieclips

  1. The movieClips, “Pen”, “Paper” and “Coffee” must be draggable. (“desk” is a movie clip on the bottom layer that is not not draggable)

  2. “Pen” and “Coffee” may be able to be released on top of “paper”. However, “Paper” and “Pen” may not be released on top of “Coffee” for visual reasons. (realistically, The paper couldn’t sit on top of the coffee cup without bending, so I’d rather it not be possible at all)

Small note: All 3 draggable items should be capable of being released anywhere on top of the “desk”.

  1. Lastly, all 3 Items cannot be released from dragging with a portion of their shape sticking out of view of the stage as will be shown below.

Here are correct and incorrect examples of how the movie clips should and shouldn’t be released from dragging.

[SIZE=3][COLOR=DarkGreen]Correct Example of StopDrag[/COLOR][/SIZE]
Click this link to view jpg example

[SIZE=3][COLOR=Darkred]Incorrect Example of StopDrag[/COLOR][/SIZE]
Click this link to view jpg example

Ideally, when one movie clip is being dragged towards the outside boundry, I’d like it to be released from being dragged once the tip of the movieclip reaches the boundry, so that it does not appear to be half sticking outside of the flash movie.

As well, I’d like the same thing to happen when for instance the Paper is released ontop of the coffee. I’d like it not to be draggable, or relased on top of the coffee.

Here is the fla file: FLA file

Here, you can view the swf: swf file

Thanks. I hope I was clear enough with my explanations and descriptions.

Livi