as3 droptarget

Posted on 2011-09-21
Medium Priority
Last Modified: 2013-11-11
I'm doing a drag and drop interaction.  The very basic code is

function mouseDown(event:MouseEvent):void

function mouseReleased(event:MouseEvent):void
	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.
Question by:moglie
LVL 29

Accepted Solution

dgofman earned 2000 total points
ID: 36577626
If you are using DragManager class


You should control all your drop target(s) by acceptDragDrop API


Author Comment

ID: 36577691
Not using Flex or any ui components.  The draggable objects and droptargets are just movieclips.
LVL 29

Assisted Solution

dgofman earned 2000 total points
ID: 36577704
But DragManager is not for Flex is ActionScript 3 class.

Check this example its pure AS

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

LVL 29

Expert Comment

ID: 36577733
Check this tutorial it will tell you basic steps

LVL 29

Expert Comment

ID: 36577739
and in step 2 showing how to control drop target

LVL 10

Expert Comment

ID: 36581721
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.
LVL 37

Expert Comment

ID: 37337072
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

624 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question