flash drag and drop

We have 2 drag and drop movieclips

// start points
var start1x:Number = drag1_mc._x;
var start1y:Number = drag1_mc._y;
var start2x:Number = drag2_mc._x;
var start2y:Number = drag2_mc._y;

// start drags…
drag1_mc.onPress = function() {
startDrag(this);
};
drag2_mc.onPress = function() {
startDrag(this);
};

//
// drop them..
// drag 1 gets dropped on drop1 else goes back to start position
drag1_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == drop1_mc) {
this._x = drop1_mc._x+drop1_mc._width/4;
this._y = drop1_mc._y+drop1_mc._height/4;
} else {
this._x = start1x;
this._y = start1y;
}
};
// .35
drag2_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == drop2_mc) {
this._x = drop2_mc._x+drop2_mc._width/4;
this._y = drop2_mc._y+drop2_mc._height/4;
} else {
this._x = start2x;
this._y = start2y;
}
};

Leave a Reply

You must be logged in to post a comment.