Solved

as3 droptarget

Posted on 2011-09-21
8
1,579 Views
Last Modified: 2013-11-11
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.
0
Comment
Question by:moglie
8 Comments
 
LVL 29

Accepted Solution

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

http://livedocs.adobe.com/livecycle/8.2/programLC/common/langref/mx/managers/DragManager.html

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

http://livedocs.adobe.com/flex/3/html/dragdrop_7.html
0
 

Author Comment

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

Assisted Solution

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

Check this example its pure AS

http://icodesnippet.com/snippet/actionscript-3/as3-drag-n-drop
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 29

Expert Comment

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

http://www.youtube.com/watch?v=ALqGYMsRWxw
0
 
LVL 29

Expert Comment

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

http://www.youtube.com/watch?NR=1&v=1hR3CVIdfuY
0
 
LVL 10

Expert Comment

by:Carnou
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.
0
 
LVL 37

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now