PDA

View Full Version : drag & drop multiple targets


ad441
10-03-2003, 07:37 AM
This is probably a really stupid question, but I'm compeltely stuck with this - I've got a draggable clip and a drop zone - when the clip is dropped on this zone it jumps to a frame 10, this works fine. I now want to add anotehr drop zone 'sweet', which draggng the clip onto will jump to a frame 20. I'm sure it must be relatively simple to add this one into the below code, but I've been trying for ages and just can't get it formatted right - can antyone help?
This is the script which i have working, presumably I need to add another 'if' in, or possibly an 'else if', pointing to my other drop zone. Just not sure how to...

on (press) {
startDrag("", true);
}
on (release) {
stopDrag();
/:DropName = getProperty("", _droptarget);
if (/:DropName eq "/drop zone not sweet") {
tellTarget ("/") {
gotoAndPlay(10);
}
}
}

ad441
10-03-2003, 10:45 AM
Ok, in the hope of increasing the chances of someone answering, I've posted a copy of the file to

http://www.downie4.demon.co.uk/sweeet.fla

if anyone can tell me how to make both drop targets work, I'd be really, really grateful...

thanks
AD

Xenozip
10-03-2003, 01:38 PM
What version of flash are you using?

Try this : on (press) {
startDrag(this);
}
on (release) {
stopDrag();
_root.DropName = eval(this._droptarget)._name;
if (_root.DropName == undefined) {
with (this) {
_root.text = "undefined"
gotoAndPlay(10);
}
}
}

ad441
10-03-2003, 01:43 PM
Thanks,
I'm using MX. I'll give that a go, though I'm still a bit confused as to where to put the other drop target (the one that jumps to frame 20).

ad441
10-03-2003, 01:58 PM
Tried it, but I don't seem to be able to configure it to my movie clips/targets - my knowledge of action script is pretty limited though, I've only really used flash for animation before and I'm finding it hard to adjust to using scripts for all but the most basic things. So I'm probably making some pretty basic mistakes.
Thanks

snapple
10-03-2003, 02:07 PM
Start from scratch - make three MovieClips, two drop targets, with instance names "dropTargetOne" and "dropTargetTwo" - then make an mc called ball and put this code on it:


on(press)
{
startDrag(this, true);
}

on(release)
{
stopDrag();

if(this._droptarget == "/dropTargetOne")
{

trace("you got it right, go and get lashed");

if(this._droptarget == "/dropTargetTwo")
{

trace("you chose the other one");
}
}
}

Xenozip
10-03-2003, 02:10 PM
Have you gone through all the tutorials yet?

Flash comes with two drag and drop tutorials that may help. The actiopnscript tutorial may seem extremely complex at first, but really it's not. It all depends on how you look at it.

The other tutorial *is* complex, and it took me some time to understand that one.

Anyway, after you look through the actionscript tutorial that comes with flash, try looking through these :

Drag 'n Drop and Drop Targets (http://www.actionscript.org/tutorials/beginner/drag-n-drop/index.shtml)
Jigsaw Puzzle (http://www.actionscript.org/tutorials/intermediate/Jigsaw_Puzzle/index.shtml)
Library (query=drag) (http://www.actionscript.org/actionscripts_library/main/search.cgi?query=drag)

ad441
10-03-2003, 03:51 PM
I tried that code and it seems to work, but can't work out how to substitute the 'trace' parts with a script to jump to certain frames. Is that simple to do?

I did the drag and drop tutorial, but i don't understand how to make that apply to more than one target. I should probably try the other ones.

Xenozip
10-03-2003, 04:11 PM
Originally posted by ad441
I tried that code and it seems to work, but can't work out how to substitute the 'trace' parts with a script to jump to certain frames. Is that simple to do? Try this: on (press) {
startDrag(this, true);
}
on (release) {
stopDrag();
if (this._droptarget == "/dropTargetOne") {
_root.dropTargetOne.gotoAndStop(10);
trace("you got it right, go and get lashed");
}
if (this._droptarget == "/dropTargetTwo") {
_root.dropTargetTwo.gotoAndStop(10);
trace("you chose the other one");
}
}