drag and drop 2
new drag and drop code..
puts it in the center every time guaranteed.
…
stop();
// set up variables for start positions for draggers
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 drag 1
drag1_mc.onPress = function() {
startDrag(this);
};
drag2_mc.onPress = function() {
startDrag(this);
};
// drop 1
drag1_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == drop1_mc) {
this._x = drop1_mc._x+drop1_mc._width/2-drag1_mc._width/2;
this._y = drop1_mc._y+drop1_mc._height/2-drag1_mc._height/2;
}else{
this._x = start1x;
this._y = start1y;
}
};
// drop 2
drag2_mc.onRelease = function() {
this.stopDrag();
if (eval(this._droptarget) == drop2_mc) {
this._x = drop2_mc._x +drop2_mc._width/2-drag2_mc._width/2;
this._y = drop2_mc._y+drop2_mc._height/2-drag2_mc._height/2;
}else{
this._x = start2x;
this._y = start2y;
}
};
