AS3 return dropped object to initial location
i am using codes from
http://hub.tutsplus.com/tutorials/create-a-drag-and-drop-puzzle-in-actionscript-30--active-2920
to make a drag and drop decoration game. i am trying to make it so that
when the dropped object is dragged out of target location (which is an
outline of the shape in my case), it goes back to initial location...
basically reversing the drag and drop. i've been messing around with
really random codes and so far this line is the closest to what i want but
i dont think the code is right and also it doesnt return to initial
location, it just goes to the side of the stage .. any help is
appreciated...
so, i added the else if line to stopDragObject which got the object to be
removed from target location, but it randomly goes to the side of the
stage, and not initial location:
private function stopDragObject(evt:MouseEvent):void {
if (evt.target.hitTestObject(getChildByName(evt.target.name +
"Target"))) {
evt.target.x = getChildByName(evt.target.name + "Target").x;
evt.target.y = getChildByName(evt.target.name + "Target").y;
} else if (evt.target.x = null) {
evt.target.x = xPos;
evt.target.y = yPos;
}
evt.target.stopDrag();
}
No comments:
Post a Comment