PDA

View Full Version : Intelligent drop targets?


sasco
09-13-2004, 03:32 AM
I am wondering if there is any way for a symbol to react on its own to having other symbols dragged on to it. For example I would like to have a chunk of code executed from within the drop target when a specific symbol is dragged and dropped onto it. I also need the drop target to be intelligent in the sense that it can react differently depending on the instance name of the object dropped onto it.

Here is what I am trying to acomplish. 3 symbols with a CD icon in them. Each will have its own instance name. 1 symbol that looks like a CD player. When a CD is dropped onto the player the player symbol will read the CD instance name and display it in a text box. Something along those lines.

I have looked at loads of different drag and drop tutorials and have come up with nothing. Any help would be greatly appreciated.

-Matt

*EDIT* I changed the title of this post because I felt that it was too vague and didn't really ask a question.

snapple
09-13-2004, 11:12 AM
sasco,

There are tutorials for exactly that on this very site:

Beginner one is here:

http://www.actionscript.org/tutorials/beginner/drag-n-drop/index.shtml

More advanced one is here:

http://www.actionscript.org/tutorials/intermediate/Drag_and_Drop_Disk_Menu/index.shtml

Regards, snapple :)

sasco
09-13-2004, 12:13 PM
actually, I read both of those tutorials and that's not what I had in mind. As I stated in my question I was wondering if there was a way of the actual drop target responding to the objects. In both of those tutorials, it's the objects that are being dropped that are triggering code to be executed.

My problem arises when I have a hundred or lets say even more objects that have draggable capabilities. By using those tutorials I would have to write the code to trigger drop target events inside each and every draggable object.

What I am wondering is if it's possible to bypass that by using some sort of listener that catches objects being dropped and responds accordingly. This would mean my triggering code is stored in one location instead of being replicated for each and every draggable object.

-Matt