Link to home
Start Free TrialLog in
Avatar of moglie
moglie

asked on

as3 droptarget

I'm doing a drag and drop interaction.  The very basic code is

function mouseDown(event:MouseEvent):void
{
	event.currentTarget.startDrag();
}


function mouseReleased(event:MouseEvent):void
{
	event.currentTarget.stopDrag();
	if (event.currentTarget.dropTarget != null)
	{		
		event.currentTarget.x = event.currentTarget.dropTarget.parent.x;
		event.currentTarget.y = event.currentTarget.dropTarget.parent.y;
	}	
}

Open in new window


I'll have several draggable objects and droptargets.  Now the problem I have is if a given droptarget already has something dropped on it, it shouldn't allow anything else to be dropped on it ie. "disabled".  If I drag the object off of it, that particular target would need to be "enabled" again.  Haven't come up with any idea on how to do this.

Oh yeah, all the draggable objects are able to be dropped on all of the droptargets.  I'll evaluate whether the correct objects have been dropped on the correct targets later.
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of moglie
moglie

ASKER

Not using Flex or any ui components.  The draggable objects and droptargets are just movieclips.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Check this tutorial it will tell you basic steps

http://www.youtube.com/watch?v=ALqGYMsRWxw
and in step 2 showing how to control drop target

http://www.youtube.com/watch?NR=1&v=1hR3CVIdfuY
Why not simply add a flag to the drop target that says there is something dropped in it? MovieClips are dynamic; you can create a new field and check to see if it exists and is set in your MouseDown event.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.