For future reference, please post your code between
[ code] and [ /code] tags (without the spaces at the front)
I think I can help withthis issue, here is the easiest way I know possible.
First start off and make your movieclip (in the code above it is called 'ball' don't worry about naming it on the stage, the code will be changed to make everything easier.
Now, double click on the movieclip to enter it and be able to edit it. Go to the layers and frames section, adn if there is more than 1 frame in the moveiclip add a new layer above it that spans the whole length of frames.
On this new layer insert the code above (with a few changes), it should look like this:
QUOTE
// first take note of original position of ball
homeX = this._x;
homeY = this._y;
// start dragging when mouse is pressed on top of ball
this.onPress = function()
{
// inside this function, "this" refers to the ball itself
this.startDrag();
// you could also force the clip's center to snap to the mouse like this:
// this.startDrag(true);
// you could also limit the area where you can drag the clip like this:
// this.startDrag(true, leftBoundary, topBoundary, rightBoundary, bottomBoundary);
}
// stop dragging when mouse is released
// it's also good to handle onReleaseOutside, as sometimes the mouse is outside the
// movie clip when it is released
this.onRelease = this.onReleaseOutside = function()
{
this.stopDrag();
// _droptarget tells you the name of the movie clip this clip was dropped on
// but it returns a string in Flash 4 format
// use eval() to convert it to a reference to a movie clip
// then see if it is the target movie clip
if(eval(this._droptarget) == target)
{
// if so, make its position equal to the target
this._x = _root.target._x;
this._y = _root.target._y;
// if you want, you can now disable drag-and-drop like so:
// delete this.onPress;
// delete this.onRelease;
// delete this.onReleaseOutside;
}
else
{
// if not, put it back at the home position
this._x = homeX;
this._y = homeY;
}
}
NOTE - this code has not been tested and may take a bit more editing before it works correctly.
<edit>
Woops, forogt to tell you this:
After you have placed the code goto the main stage and to place the movieclips simply drag adn drop multiple copies of the movieclip to the stage, they don't even need to be at different places to work correctly (wbecause of the HomeX = this._x code above.
Happy flashing

</edit>
Hope that helps.
This post has been edited by BetaWar: 4 Jun, 2008 - 11:13 AM