I have created a basic drag and drop clothing game, but I want to make the clothing items lock into position on the body when the clothing items are dragged near that position. Anyone know the correct code I should use? My code is below;
Code:
/* Drag and Drop
Makes the specified symbol instance moveable with drag and drop.
*/
Greenshirt.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);
function fl_ClickToDrag_5(event:MouseEvent):void
{
Greenshirt.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_5);
function fl_ReleaseToDrop_5(event:MouseEvent):void
{
Greenshirt.stopDrag();
}
/* Drag and Drop
Makes the specified symbol instance moveable with drag and drop.
*/
Blueshirt.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_6);
function fl_ClickToDrag_6(event:MouseEvent):void
{
Blueshirt.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_6);
function fl_ReleaseToDrop_6(event:MouseEvent):void
{
Blueshirt.stopDrag();
}
/* Drag and Drop
Makes the specified symbol instance moveable with drag and drop.
*/
blackshirts_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_1);
function fl_ClickToDrag_1(event:MouseEvent):void
{
blackshirts_mc.startDrag();
}
stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_1);
function fl_ReleaseToDrop_1(event:MouseEvent):void
{
blackshirts_mc.stopDrag();
}
/* Click to Position an Object
Moves the specified symbol instance to the x-coordinate and y-coordinate you specify.
Instructions:
1. Replace the value 200 with the x-coordinate
where you want to position the object.
2. Replace the value 100 with the y-coordinate where you want to position the object.
*/
Clear.addEventListener(MouseEvent.CLICK, fl_ClickToPosition);
function fl_ClickToPosition(event:MouseEvent):void
{
blackshirts_mc.x = 290.75;
blackshirts_mc.y = 50.95;
Greenshirt.x = 472.35;
Greenshirt.y = 50.95;
Blueshirt.x = 647.25;
Blueshirt.y = 50.95;
}
function fl_ClickToPosition(event:MouseEvent):void
{
Blackshirt.x = 290.75;
Blackshirt.y = 50.95;
Greenshirt.x = 472.35;
Greenshirt.y = 50.95;
Blueshirt.x = 647.25;
Blueshirt.y = 50.95;
}