I need some help with my drag and drop interface.
Hi, I am currently coding a drag slot which will provide a weapon with a modifier in UDK. I don't really have any flash experience but I've managed to code movie clips that drag and stop dragging with mouse input my problem is with the drag slot itself when the icon that is being dragged is released above the drag slot it doesn't snap in place this is the code that I have. wasn't sure how to format it in the forum correctly so I'm sorry if it is hard to read.
This is the code I have put together to create my instances on the stage.
public function RiccochetDragDrop()
{
// constructor code
//DragSlot
var DropZone:dropZone = new dropZone();
addChild(DropZone);
DropZone.x = 960;
DropZone.y = 830;
//Create dragable instances and place them on stage
var ExtraAmmo:extraAmmo = new extraAmmo();
addChild(ExtraAmmo);
ExtraAmmo.x = 240;
ExtraAmmo.y = 500;
var ExtraRegen:extraRegen = new extraRegen();
addChild(ExtraRegen);
ExtraRegen.x = 720;
ExtraRegen.y = 500;
var ExtraBounce:extraBounce = new extraBounce();
addChild(ExtraBounce);
ExtraBounce.x = 1200;
ExtraBounce.y = 500;
var ExtraVelocity:extraVelocity = new extraVelocity();
addChild(ExtraVelocity);
ExtraVelocity.x = 1680;
ExtraVelocity.y = 500;
//Function to detect the dragable objects I click on.
function addListeners(... objects):void
{
for (var i:int = 0; i < objects.length; i++)
{
objects.addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
objects.addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
}
}
This is where my problem lies. I'm not sure if what I'm doing is correct with the first if statement parameters. Any help or a steer in the right direction would be very much appreciated.
function stopDragObject(e:MouseEvent):void
{
if (e.target.hitTestObject(getChildByName("DropZone")))
{
//Snap dragged object to dropzone.
e.target.x = DropZone.x;
e.target.y = DropZone.y;
snap any other dragables to there original positions.
if (e.target.name = "ExtraAmmo")
{
ExtraRegen.x = ExtraRegenX;
ExtraRegen.x = ExtraRegenY;
ExtraBounce.x = ExtraBounceX;
ExtraBounce.y = ExtraBounceY;
ExtraVelocity.x = ExtraVelocityX;
ExtraVelocity.y = ExtraVelocityY;