# Drag n drop

**URL:** <https://forum.kirupa.com/t/drag-n-drop/117542>\
**Category:** Uncategorized\
**Created:** [July 28, 2004, 7:35am UTC](https://forum.kirupa.com/t/drag-n-drop/117542 "2004-07-28T07:35:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jins](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@Jins](https://forum.kirupa.com/u/Jins)\
**Post date:** [July 28, 2004, 7:35am UTC](https://forum.kirupa.com/t/drag-n-drop/117542/1 "2004-07-28T07:35:51Z")

</div>

hi, need help here.

here is the fla file. it can drag into the green box. i want to count how many grey box already have in the green box. i can drag the grey box into the green box n the code i write is just for count how many time the grey box had click it doesnt use. i want it can count how many grey box already drag into the green box.

who know pls reply me .

---

<div class="post-metadata">

**Author:** ![e\_s\_x\_s](https://avatars.discourse-cdn.com/v4/letter/e/f9ae1b/32.png) [@e\_s\_x\_s](https://forum.kirupa.com/u/e_s_x_s)\
**Post date:** [July 28, 2004, 7:45am UTC](https://forum.kirupa.com/t/drag-n-drop/117542/2 "2004-07-28T07:45:47Z")

</div>

i can’t see the fla here:)  
but try to use the x and y coodinates to find how many grey boxes in the green box.  
example: if a grey box’ \_x value, between 100 and 200, it returns true for a variable.

this solution can be improve;)

---

<div class="post-metadata">

**Author:** ![Jins](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@Jins](https://forum.kirupa.com/u/Jins)\
**Post date:** [July 28, 2004, 8:28am UTC](https://forum.kirupa.com/t/drag-n-drop/117542/3 "2004-07-28T08:28:49Z")

</div>

the fla file cant upload , error here. but it is like i have 1 big box n 4 small box. i want to drag the small box to the big box.

i put code which can drag n count time it click, but if i put all this code in the small box it just can count until 1 for me cos i just click once for each small box. i want it can count how many small box i put in the big box. do u think can i put on(release) to big box n copy the small box code to the big box , will this count for me ??

later will have go btn for user to click n will acoording the count n telltarget to which movieclip.

i dunno how to try ur’s idea which with x y coordinate.

---

<div class="post-metadata">

**Author:** ![e\_s\_x\_s](https://avatars.discourse-cdn.com/v4/letter/e/f9ae1b/32.png) [@e\_s\_x\_s](https://forum.kirupa.com/u/e_s_x_s)\
**Post date:** [July 28, 2004, 9:35am UTC](https://forum.kirupa.com/t/drag-n-drop/117542/4 "2004-07-28T09:35:41Z")

</div>

are you using startDrag or - just cilck than copy to the big box?

if the big box’s x values are between 100 and 200 , your code on the small box should be like this,

on(release){  
if(this.\_x\>100 && this.\_x\<200){  
\_root.count++  
}  
}

---

<div class="post-metadata">

**Author:** ![Jins](https://avatars.discourse-cdn.com/v4/letter/j/9de053/32.png) [@Jins](https://forum.kirupa.com/u/Jins)\
**Post date:** [July 29, 2004, 3:35am UTC](https://forum.kirupa.com/t/drag-n-drop/117542/5 "2004-07-29T03:35:19Z")

</div>

i have 4 small box so izzit i have to put the code on each of them ??  
this is wat i put on each small box’s code

```auto
 
on (press) {
startDrag(this, true);
}
on (release) {
stopDrag();
if (this._droptarget == "/green_box2") {
_root.green_box.gotoAndStop(2);
}
}

```

---

<div class="post-metadata">

**Author:** ![e\_s\_x\_s](https://avatars.discourse-cdn.com/v4/letter/e/f9ae1b/32.png) [@e\_s\_x\_s](https://forum.kirupa.com/u/e_s_x_s)\
**Post date:** [July 29, 2004, 7:15am UTC](https://forum.kirupa.com/t/drag-n-drop/117542/6 "2004-07-29T07:15:10Z")

</div>

try to use this code:

```auto

_root.onMouseUp = function() {
	for (i=1; i<5; i++) {
		if (_root["drag"+i].hitTest(green_box)) {
			trace("grey box "+i+" in the box");
		}
	}
};

```
