Random drag and drop

hi everyone!!

i have this problem about drag and drop. i have six pictures which should be able to drag and drop randomly at the six initialize drop targets. I only able to drag the first picture to only one drop target correctly. let say i drag ‘picture1’ and drop at ‘target2’…and ‘picture2’ will automatically occupy ‘target1’ where ‘picture1’ resides previously. but when i drag ‘picture1’ (now resides at ‘target2’) to ‘target6’, ‘picture6’ will go to reside at ‘target1’…actually it should reside at ‘target2’. i still have no idea how to do the random drag and drop…hope i’ll get solutions from you all!!

thanks in advance.

If the pictures are the same size, rather than complicating matters with targets, you could just get the pictures to switch x and y values if one is dropped on the other. With the way you are doing it each picture will have to remember which target it is currently on… I don’t know how to do that!

hi insomniac…here’s my coding for the first dragable picture named ‘drop1’…the pictures are all in the same size…the six drop targets are movieclip and named them ‘target’…so that if the ‘drop1’ is placed randomly at the targets…it will get the target’s x and y coordinates…i’m not sure if this is the correct way of writing the condition…but the coding doesn’t work. :frowning:

on (press) {
_alpha = 20;
this.startDrag();
}
on (release, releaseOutside) {
_alpha = 100;
stopDrag();
if (this._droptarget == “/target”) {
this._x = _root.target._x;
this._y = _root.target._y;

	_root.drop2._x = _root.target._x;
	_root.drop2._y = _root.target._y;
} 
else if (this._droptarget == "/target") {
	this._x = _root.target._x;
	this._y = _root.target._y;
	
	_root.drop3._x = _root.target._x;
	_root.drop3._y = _root.target._y;
}
else if (this._droptarget == "/target") {
	this._x = _root.target._x;
	this._y = _root.target._y;
	
	_root.drop4._x = _root.target._x;
	_root.drop4._y = _root.target._y;
}
else if (this._droptarget == "/target") {
	this._x = _root.target._x;
	this._y = _root.target._y;
	
	_root.drop5._x = _root.target._x;
	_root.drop5._y = _root.target._y;
}
else if (this._droptarget == "/target") {
	this._x = _root.target._x;
	this._y = _root.target._y;
	
	_root.drop6._x = _root.target._x;
	_root.drop6._y = _root.target._y;
} 
//go back to original place
else if (this._droptarget == "/target") {
	this._x = _root.target._x;
	this._y = _root.target._y;
	
	_root.drop1._x = _root.target._x;
	_root.drop1._y = _root.target._y;
}

}

i’ve found the solution to my problem…now i am able to do the random drag and drop :slight_smile:

the link to the tutorial is:
http://www.flashkit.com/tutorials/Actionscripting/Drag_Dr-Gorky-126/index.php

that’s pretty cool, nice one