# Drag and Drop

**URL:** <https://forum.kirupa.com/t/drag-and-drop/16174>\
**Category:** Uncategorized\
**Created:** [March 21, 2003, 8:53pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174 "2003-03-21T20:53:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![coyotekel](https://avatars.discourse-cdn.com/v4/letter/c/48db29/32.png) [@coyotekel](https://forum.kirupa.com/u/coyotekel)\
**Post date:** [March 21, 2003, 8:53pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/1 "2003-03-21T20:53:25Z")

</div>

I’ve got a drag and drop I set up using this kind of code for each of my draggable items

on (release) {  
stopDrag();  
if (this.\_droptarget=="/target1"){  
setProperty(this, \_x, 213.1);  
setProperty(this, \_y, 529.5);  
} else {  
setProperty(this, \_x, 579.9);  
setProperty(this, \_y, 287.5);  
}  
}

If I want to have an specific action take place after they are all dropped in the correct places how do I do that?

---

<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 21, 2003, 9:20pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/2 "2003-03-21T21:20:08Z")

</div>

hi coyote!

i´m not sure what you want, but…

try this:

[AS]  
on (release) {  
stopDrag();  
if (eval(this.\_droptarget) == \_root.target1) {  
this.\_x = 213;  
this.\_y = 529;  
action1;  
action2;  
} else {  
this.\_x = 579;  
this.\_y = 287;  
}  
}  
[/AS]

were action1 and 2 are the actions that will happen if **this** object is droped on the **target1**.

---

<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 21, 2003, 9:23pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/3 "2003-03-21T21:23:42Z")

</div>

Sorry it’s so hard for me to explain myself clearly because I’m fairly new at the flash lingo.

:-\ Ok let’s see, I have many objects that are draggable and have to be dropped to one of two boxes.

If they are dropped to the incorrect box they snap back; if the correct box they stay. I need a specific action to take place when ALL of them are dropped correctly. Did that help? Hope so.

🙂

---

<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 21, 2003, 9:34pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/4 "2003-03-21T21:34:09Z")

</div>

oh… ok:

lets say you have four objects to be dragged

place this code on the draggable objects:  
[AS]  
on (release) {  
stopDrag();  
if (eval(this.\_droptarget) == \_root.target1) {  
this.\_x = 213;  
this.\_y = 529;  
\_root.draggedOk++;  
} else {  
this.\_x = 579;  
this.\_y = 287;  
}  
}  
[/AS]

create a movieclip (blank if you will) and place this code in it:  
[AS]  
onClipEvent (load) {  
\_root.draggedOk=0;  
}  
onClipEvent (enterFrame) {  
if (\_root.draggedOk\>=4){  
doThis;  
}  
}  
[/AS]

did you understand it? need explanations?

---

<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 21, 2003, 9:57pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/5 "2003-03-21T21:57:13Z")

</div>

I think I’ve got it. Let me give it a shot and I’ll let you know.

---

<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 21, 2003, 11:18pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/6 "2003-03-21T23:18:27Z")

</div>

cool =) let me know the result 😉

---

<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 21, 2003, 11:59pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/7 "2003-03-21T23:59:41Z")

</div>

Ok it’s sort of working.  
The action I want to happen is for a button to blink so if i set an action to go to a certain frame it will loop until it’s clicked. (and it’s working everywhere else) I just have the action at the end of each movie clip.

It’s going to the frame and stopping instead of playing. So the button turns red but stays that way. Here’s the script on the blank movie clip

onClipEvent (load) {  
\_root.draggedOK=0;  
}  
onClipEvent (enterFrame) {  
if (\_root.draggedOK\>=6){  
\_root.blinkmc.gotoandplay(2)  
}  
}

whatcha think?

---

<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 22, 2003, 12:46am UTC](https://forum.kirupa.com/t/drag-and-drop/16174/8 "2003-03-22T00:46:07Z")

</div>

**1.** dynamic event handler

in the timeline you’d have a script like this

```auto
draggedOK = 0;
this.onEnterFrame = function() {
	if (draggedOK >= 6) {
		blinkmc.gotoAndPlay(2);
		delete this.onEnterFrame;
	}
}

```

**2.** flag

you can use this one in the movie clip actions

```auto
onClipEvent (load) {
	_root.draggedOK = 0;
}
onClipEvent (enterFrame) {
	if (!ok && _root.draggedOK >= 6) {
		_root.blinkmc.gotoAndPlay(2);
		ok = true;
	}
}

```

---

<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 22, 2003, 8:50am UTC](https://forum.kirupa.com/t/drag-and-drop/16174/9 "2003-03-22T08:50:30Z")

</div>

yep, kax code is better.  
and your mistake was in the …gotoandplay… were should be …goto **A** nd **P** lay… 😉

---

<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 22, 2003, 9:04am UTC](https://forum.kirupa.com/t/drag-and-drop/16174/10 "2003-03-22T09:04:09Z")

</div>

hey **guigo** … =)  
remember that **gotoAndPlay()** is not case sensitive …

gotoandplay() works too …  
although it’s **not** a good habit :-\

i guess my point is … it works? yes. but i’m with you, it’s a mistake 😉

---

<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 22, 2003, 9:45am UTC](https://forum.kirupa.com/t/drag-and-drop/16174/11 "2003-03-22T09:45:40Z")

</div>

i didn´t knew about that… thanks kax! =)

it´s like i always say: live and read kax´s posts to learn 😉 😛

---

<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 22, 2003, 9:57am UTC](https://forum.kirupa.com/t/drag-and-drop/16174/12 "2003-03-22T09:57:10Z")

</div>

> _Originally posted by Guig0_  
> **it’s like i always say: live and read kax’s posts to learn 😉 😛**

wow! that’s so flattering :beam: 😛

😉 =)

---

<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 24, 2003, 1:41pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/13 "2003-03-24T13:41:56Z")

</div>

That’s not working. Still just goes to the second frame and stops.

---

<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 24, 2003, 1:47pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/14 "2003-03-24T13:47:49Z")

</div>

there must be a **stop** action somewhere at frame 2… ?? :-\

---

<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 24, 2003, 1:50pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/15 "2003-03-24T13:50:17Z")

</div>

No there’s not. This clip plays at the end of every other movie clip no problem. I don’t get it.

Confused:\*(

---

<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 24, 2003, 1:54pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/16 "2003-03-24T13:54:53Z")

</div>

can you post your fla?

---

<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 24, 2003, 1:58pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/17 "2003-03-24T13:58:31Z")

</div>

No it’s too big.

☹ ☹

---

<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 24, 2003, 2:02pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/18 "2003-03-24T14:02:09Z")

</div>

can you link it to us? :q:

if not, mail it to me: [COLOR=orangered]g u i g 0 \_ r j @ y a h o o . c o m . b r [/COLOR]

---

<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 24, 2003, 2:04pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/19 "2003-03-24T14:04:26Z")

</div>

> _Originally posted by coyotekel_  
> \*\*No it’s too big.

☹ :(\*\*

make a copy of the file and remove everything irrelevant to the problem 😉

---

<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 24, 2003, 2:04pm UTC](https://forum.kirupa.com/t/drag-and-drop/16174/20 "2003-03-24T14:04:36Z")

</div>

I could email it.

[Next page](https://forum.kirupa.com/t/drag-and-drop/16174.md?page=2)
