Solved

as3 droptarget

Posted on 2011-09-21
8
1,611 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
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.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

728 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