Drop Target

hi,

Can someone help me to achieve the following?

see .fla

Thx

Mel*

first off:

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

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 .
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 :wink:

Cheers :bounce:

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*

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. :slight_smile:

you´re welcome :wink:

did you understand the code?

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?

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

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;
}
}

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 :wink:

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.

wait a min…

check this out:

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;
}

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:

:stuck_out_tongue: :stuck_out_tongue:

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.

in the mean time…

try this:

change this line:

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

to:

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

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]

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.

it works now,…the “garbage lines” were a desperate attempt :slight_smile:
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 !!

:slight_smile:

Mel*

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

i´m a designer too :wink:

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

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;
}
}