Drag and drop then SNAP BACK TO ORIGIN → URGENT HELP PLEASE

THANKS FOR ANY HELP! :slight_smile:

5 text choices (choice_1 → choice_5)
5 text field targets (box_1 → box_5)

FUNCTION:

  1. Drag the choices to the targets.
  2. When dropped they display in target fields.
  3. Then snap back.

I thought I had it but no cigar … must be close though.

Everything functions properly EXCEPT when I drag a choice and drop it all five choices go to choice_5 (XY) instead of their own origin.

HOW DO I SOLVE THIS?

PROBLEM CAN BE SEEN HERE

paintedthetown.com/draganddrop.php

[CODE ]

import flash.net.URLVariables;
import flash.net.URLRequest;

var origX:Number;
var origY:Number;

origX = choice_1.x;
origY = choice_1.y;

choice_1.buttonMode = true;
choice_1.mouseChildren = false;
choice_1.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);

function fl_ClickToDrag(event:MouseEvent):void
{
choice_1.startDrag();
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);

function fl_ReleaseToDrop(event:MouseEvent):void
{
choice_1.stopDrag();

if(choice_1.hitTestObject(box_1))
{
box_1.text = choice_1.text;
}

if(choice_1.hitTestObject(box_2))
{
box_2.text = choice_1.text;
}

if(choice_1.hitTestObject(box_3))
{
box_3.text = choice_1.text;
}

if(choice_1.hitTestObject(box_4))
{
box_4.text = choice_1.text;
}

if(choice_1.hitTestObject(box_5))
{
box_5.text = choice_1.text;
}

choice_1.x = origX;
choice_1.y = origY;
}

// CHOICE 2

origX = choice_2.x;
origY = choice_2.y;

choice_2.buttonMode = true;
choice_2.mouseChildren = false;
choice_2.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_2);

function fl_ClickToDrag_2(event:MouseEvent):void
{
choice_2.startDrag();
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);

function fl_ReleaseToDrop_2(event:MouseEvent):void
{
choice_2.stopDrag();

if(choice_2.hitTestObject(box_1))
{
box_1.text = choice_2.text;
}

if(choice_2.hitTestObject(box_2))
{
box_2.text = choice_2.text;
}

if(choice_2.hitTestObject(box_3))
{
box_3.text = choice_2.text;
}

if(choice_2.hitTestObject(box_4))
{
box_4.text = choice_2.text;
}

if(choice_2.hitTestObject(box_5))
{
box_5.text = choice_2.text;
}

choice_2.x = origX;
choice_2.y = origY;
}

//CHOICE 3

origX = choice_3.x;
origY = choice_3.y;

choice_3.buttonMode = true;
choice_3.mouseChildren = false;
choice_3.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_3);

function fl_ClickToDrag_3(event:MouseEvent):void
{
choice_3.startDrag();
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_3);

function fl_ReleaseToDrop_3(event:MouseEvent):void
{
choice_3.stopDrag();

if(choice_3.hitTestObject(box_1))
{
box_1.text = choice_3.text;
}

if(choice_3.hitTestObject(box_2))
{
box_2.text = choice_3.text;
}

if(choice_3.hitTestObject(box_3))
{
box_3.text = choice_3.text;
}

if(choice_3.hitTestObject(box_4))
{
box_4.text = choice_3.text;
}

if(choice_3.hitTestObject(box_5))
{
box_5.text = choice_3.text;
}

choice_3.x = origX;
choice_3.y = origY;
}

// CHOICE 4

origX = choice_4.x;
origY = choice_4.y;

choice_4.buttonMode = true;
choice_4.mouseChildren = false;
choice_4.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_4);

function fl_ClickToDrag_4(event:MouseEvent):void
{
choice_4.startDrag();
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_4);

function fl_ReleaseToDrop_4(event:MouseEvent):void
{
choice_4.stopDrag();

if(choice_4.hitTestObject(box_1))
{
box_1.text = choice_4.text;
}

if(choice_4.hitTestObject(box_2))
{
box_2.text = choice_4.text;
}

if(choice_4.hitTestObject(box_3))
{
box_3.text = choice_4.text;
}

if(choice_4.hitTestObject(box_4))
{
box_4.text = choice_4.text;
}

if(choice_4.hitTestObject(box_5))
{
box_5.text = choice_4.text;
}

choice_4.x = origX;
choice_4.y = origY;
}

// CHOICE 5

origX = choice_5.x;
origY = choice_5.y;

choice_5.buttonMode = true;
choice_5.mouseChildren = false;
choice_5.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag_5);

function fl_ClickToDrag_5(event:MouseEvent):void
{
choice_5.startDrag();
}

stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_5);

function fl_ReleaseToDrop_5(event:MouseEvent):void
{
choice_5.stopDrag();

	if(choice_5.hitTestObject(box_1))
{
box_1.text = choice_5.text;
}

if(choice_5.hitTestObject(box_2))
{
box_2.text = choice_5.text;
}

if(choice_5.hitTestObject(box_3))
{
box_3.text = choice_5.text;
}

if(choice_5.hitTestObject(box_4))
{
box_4.text = choice_5.text;
}

if(choice_5.hitTestObject(box_5))
{
box_5.text = choice_5.text;
}

choice_5.x = origX;
choice_5.y = origY;
}