Drag and Drop w/ multiple hit targets

Well, here I am again…STUMPED, LOL!!!

Basically, I’m trying to create something that will let me drag an object (object_A) onto a hit area (object_B) and give it the exact same x and y coordinates as object_B.

I know object_A has to be a movie clip with a button inside of it and that the code has to go on the button, not the movie (because the ‘drag’ function only works with a handler like on_press for example).

Anyways, this is the code that I have right now:

on (press) {
on (release) {
if (eval(object_A._droptarget) == _root.object_B) {
object_A._visible = false;
} else {
object_A._x = x_480;
object_A._y = y_90;


The other catch is…object_A needs to be able to be dropped onto several possible hit targets, not just object_B (eg. object_C and object_D).

Not sure if it makes any sense to anybody but, if you have any ideas they would be greatly appreciated!

//there are two arrays generated one for drag and the other for drop and you are getting who was dragged and on whom was dropped.

var xPos:Number;
var yPos:Number;
var myDragArray:Array = new Array();
var myDropArray:Array = new Array();
//drag portion ///////////////////////////////
for (i=0; i<myDragArray.length; i++) {
eval(myDragArray*).onPress = function() {
xPos = this._x;
yPos = this._y;
//drop portion /////////////////////////////
eval(myDragArray*).onRelease = eval(myDragArray*).onReleaseOutside=function () {
if (eval(myDragArray*._droptarget) == eval(myDropArray*)) {// this is the correct
//if (eval(this._droptarget) == eval(myDropArray*)) {
trace(“dropped on :”+this._droptarget+" Who was dropped :"+this._name);
whereDrop = eval(this._droptarget);
if (whereDrop == undefined) {
//trace("would call snap original ");//This would call snap original
snapOriginal(this, xPos, yPos);
} else {
//trace("would snap to its destination "+whereDrop);// this would be dopped on the target object.
snapToObject(this, whereDrop);
//function to snap at original point. /////////////////////////////
function snapOriginal(dragName, xPosition, yPosition) {
//trace(“snap original function :”+dragName+xPosition +yPosition);
dragName._x = xPos;
dragName._y = yPos;
//function to snap at the object ////////////////////////
function snapToObject(drag, drop) {
drag._x = drop._x;
drag._y = drop._y;

do you need buttons to create your drag and drop only.