# Drop Target

**URL:** <https://forum.kirupa.com/t/drop-target/16464>\
**Category:** flash\
**Created:** [March 25, 2003, 1:55pm UTC](https://forum.kirupa.com/t/drop-target/16464 "2003-03-25T13:55:26Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Melissa\_Anne](https://avatars.discourse-cdn.com/v4/letter/m/49beb7/32.png) [@Melissa\_Anne](https://forum.kirupa.com/u/Melissa_Anne)\
**Post date:** [March 25, 2003, 1:55pm UTC](https://forum.kirupa.com/t/drop-target/16464/1 "2003-03-25T13:55:26Z")

</div>

hi,

Can someone help me to achieve the following?

see .fla

Thx

Mel\*

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2003, 2:15pm UTC](https://forum.kirupa.com/t/drop-target/16464/2 "2003-03-25T14:15:28Z")

</div>

first off:

you didn´t even try… but since i´m feeling generous today…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2003, 2:36pm UTC](https://forum.kirupa.com/t/drop-target/16464/3 "2003-03-25T14:36:15Z")

</div>

mel,

a good piece of advice is for you to first try on your own… if you have problems at this point, just read [**this**](http://www.kirupa.com/developer/fullindex.htm) .  
then, if you find any dificulties, post your problem, with a good description of what you need and how you got there.

that way you will help us to help you 😉

Cheers :bounce:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2003, 2:58pm UTC](https://forum.kirupa.com/t/drop-target/16464/4 "2003-03-25T14:58:44Z")

</div>

No i did try but didnt send the original work. I simplify the fla so i could get some help. I could do the startdrag but i couldnt get the object to fall in a specific area … (I have several objects that I would like to drop in a container).

thank you for helping!

Mel\*

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2003, 3:03pm UTC](https://forum.kirupa.com/t/drop-target/16464/5 "2003-03-25T15:03:41Z")

</div>

Here’s the drag and drop fla with \_droptargets that I wrote a while back. It’s in another similar thread in here too, but might as well include again. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2003, 3:07pm UTC](https://forum.kirupa.com/t/drop-target/16464/6 "2003-03-25T15:07:16Z")

</div>

you´re welcome 😉

did you understand the code?

```auto
on (press) {
	startDrag(this, false);
}
on (release) {
	stopDrag();
	[COLOR=red]if (eval(this._droptarget) == _root.dropBox) {
		this._x = _root.dropBox._x;
		this._y = _root.dropBox._y;
	}[/COLOR][COLOR=green] else {
		this._x = 100;
		this._y = 100;
	}[/COLOR]
}

```

the red part checks if you droped the object on the dropBox, if you did it will liein the same position of the dropBox, you can change the value of those lines:  
this.\_x = \_root.dropBox.\_x;  
this.\_y = \_root.dropBox.\_y;  
to numerical, such as:  
this.\_x = 200;  
this.\_y = 200;

and the green part tells to the object where it should be placed if it wasn´t droped on the dropBox.

do you have any questions yet?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 25, 2003, 3:13pm UTC](https://forum.kirupa.com/t/drop-target/16464/7 "2003-03-25T15:13:14Z")

</div>

no thanks  
i was about to ask you about the values but you posted before… i am going to read carefully first !

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 4:44pm UTC](https://forum.kirupa.com/t/drop-target/16464/8 "2003-03-26T16:44:51Z")

</div>

It works fine alone, but when i make it an external swf (I have the “drag and drop” scene is a separate movie)and play the main movie it doesnt , but i dont understand because in the code the path is set to \_root.

Here was the code applied to the mcs that were dragged:  
I think i have to change something since it doesnt work when launched as external swf.

on (press) {  
startDrag(this, false);  
}  
on (release) {  
stopDrag();  
if (eval(this.\_droptarget) == \_root.dro2) {  
this.\_x = 168.4;  
this.\_y = 310.5;  
} else {  
this.\_x = 632.9;  
this.\_y = 150.0;  
}  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 5:56pm UTC](https://forum.kirupa.com/t/drop-target/16464/9 "2003-03-26T17:56:38Z")

</div>

change this line:

if (eval(this.\_droptarget) == \_root.dro2) {

to:

if (eval(this.\_droptarget) == dro2) {

or:

if (eval(this.\_droptarget) == \_level#.dro2) {

# = level of the loaded movie.

and tell me if it works 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 6:15pm UTC](https://forum.kirupa.com/t/drop-target/16464/10 "2003-03-26T18:15:05Z")

</div>

tried both with “\_level” or nothing but that didnt work.

I forgot to tell that it is actually a second level external .swf , that means that on my main scene i have an action on the frame , that loads an external swf (one.swf) in which i have again another action on frame loading this second external swf(second swf) in which the “drag & drop” mc is located.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 6:17pm UTC](https://forum.kirupa.com/t/drop-target/16464/11 "2003-03-26T18:17:53Z")

</div>

wait a min…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 6:35pm UTC](https://forum.kirupa.com/t/drop-target/16464/12 "2003-03-26T18:35:47Z")

</div>

check this out:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 7:33pm UTC](https://forum.kirupa.com/t/drop-target/16464/13 "2003-03-26T19:33:13Z")

</div>

I also load the external file in empty Mcs…

I tried the levels like you did but i probably have a mistake in the code… does that seem correct to you ?

on (press) {  
emptymc1.loadMovie(“movie\_level1.swf”);  
emptymc1.\_x = 0;  
emptymc1.\_y = 0;  
emptymc1.\_level = 1;  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 8:04pm UTC](https://forum.kirupa.com/t/drop-target/16464/14 "2003-03-26T20:04:28Z")

</div>

> I also load the external file in empty Mcs…

why can´t you just tell me exactly what you want in the first hand :q:

you´re not helping me to help you :bad:

😛 😛

that´s why it isn´t working… if you´re not loading in to levels you can target in to levels…

show me the code that you´re loading the movies. all of them.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 8:08pm UTC](https://forum.kirupa.com/t/drop-target/16464/15 "2003-03-26T20:08:52Z")

</div>

in the mean time…

try this:

change this line:

if (eval(this.\_droptarget) == \_root.dro2) {

to:

if (eval(this.\_droptarget) == \_root.emptymc1.dro2) {

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 8:14pm UTC](https://forum.kirupa.com/t/drop-target/16464/16 "2003-03-26T20:14:39Z")

</div>

here you go:  
in my main movie on frame, i have:

stop();  
emptymc1.loadMovie(“part1.swf”);  
emptymc1.\_x = 0;  
emptymc1.\_y = 0;  
emptymc1.\_level=1 (here i am not sure)

in part1.swf, i have :  
stop();  
empt2.loadMovie(“part2.swf”);  
empt2.\_x = -150;  
empt2.\_y = 0;  
emptymc2.\_level=2 (here i am not sure)

in part2.swf, the action on the mcs(draggable objects) i have:

on (press) {  
startDrag(this);  
}  
on (release) {  
stopDrag();  
if (eval(this.\_droptarget) == \_level2.dro5) {  
this.\_x = 298.9;  
this.\_y = 79.5;  
} else {  
this.\_x = 620.9;  
this.\_y = 255.0;  
}  
}

\*\*[COLOR=orangered][COLOR=orangered][COLOR=orangered]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 8:32pm UTC](https://forum.kirupa.com/t/drop-target/16464/17 "2003-03-26T20:32:26Z")

</div>

first:

loose the (here i am not sure) lines, they´re are garbage.

second:

use this code on the draggable objects:

on (press) {  
startDrag(this);  
}  
on (release) {  
stopDrag();  
if (eval(this.\_droptarget) == \_root.emptymc1.dro2) {  
this.\_x = 298.9;  
this.\_y = 79.5;  
} else {  
this.\_x = 620.9;  
this.\_y = 255.0;  
}  
}

if that doesn´t work post your FLAs here.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 8:52pm UTC](https://forum.kirupa.com/t/drop-target/16464/18 "2003-03-26T20:52:39Z")

</div>

it works now,…the “garbage lines” were a desperate attempt 🙂  
also as you can see i am not a scripter but more of a designer trying to compose with AS!  
thank you so much for your patience and help !!

🙂

Mel\*

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 8:58pm UTC](https://forum.kirupa.com/t/drop-target/16464/19 "2003-03-26T20:58:26Z")

</div>

no problem mel, i´m glad to help you =)

i´m a designer too 😉

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 26, 2003, 9:06pm UTC](https://forum.kirupa.com/t/drop-target/16464/20 "2003-03-26T21:06:43Z")

</div>

actually the code worked on the 1st level but not 2nd so i change that in it worked…🙂

on (press) {  
startDrag(this);  
}  
on (release) {  
stopDrag();  
if (eval(this.\_droptarget) == \_root.emptymc1.emptymc2.dro2) {  
this.\_x = 298.9;  
this.\_y = 79.5;  
} else {  
this.\_x = 620.9;  
this.\_y = 255.0;  
}  
}
