PDA

View Full Version : Flash retun mc to first position


ianhull
07-20-2005, 09:51 AM
Hi Guys,

a little flash problem here if any of you would be kind enough to help.

I am using drag and drop with targets in Flash but if the drag object is not dropped onto the corect target I would like it to return to the start position on the bottom of the movie so the user can try again.

here is what I have upto now which works fine.

//

on (press)
{
startDrag(this, false);
_root.answer1 = "";
}
on (release)
{
stopDrag();
if (this._droptarget != "/a2")
{
_root.answer1 = "wrong"; // Instead of this I would like the movie clip t1 to return to the start position.
}
else
{
_root.answer1 = "Correct";
} // end if
}


Any help will be greatly apprecited.

Thanks in advance.

Corey
07-20-2005, 04:17 PM
Hi. There's a few different ways. One easy way is to store the objects co-ordinates on startDrag, i.e.:

on (press)
{
origX = this._x;
origY = this._y;
startDrag(this, false);
_root.answer1 = "";
}

And then you can restore it here if you need:

if (this._droptarget != "/a2")
{
this._x = origX;
this._y = origY;
_root.answer1 = "wrong";
}

I didn't check the code but it should work. Hope that helps. :)