# Problem in drag and drop

**URL:** <https://forum.kirupa.com/t/problem-in-drag-and-drop/173198>\
**Category:** Uncategorized\
**Created:** [December 22, 2005, 6:47am UTC](https://forum.kirupa.com/t/problem-in-drag-and-drop/173198 "2005-12-22T06:47:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ammu](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@ammu](https://forum.kirupa.com/u/ammu)\
**Post date:** [December 22, 2005, 6:47am UTC](https://forum.kirupa.com/t/problem-in-drag-and-drop/173198/1 "2005-12-22T06:47:22Z")

</div>

var applex, appley, waterx, watery;  
count = 0;  
apple.onPress = function() {  
count += 1;  
applex = apple.\_x;  
appley = apple.\_y;  
\_root.apple.duplicateMovieClip(“apple”+count, count);  
dupapple = eval(“apple”+count);  
startDrag(dupapple);

dupapple.onRelease = function() {  
stopDrag();  
process(dupapple);  
};  
}  
water.onPress = function() {  
count += 1;  
\_root.water.duplicateMovieClip(“water”+count, count);  
dupwater = eval(“water”+count);  
startDrag(dupwater);

dupwater.onRelease = function() {

stopDrag();  
process(dupwater);  
};  
}  
function process(arg) {  
if (arg.hitTest(\_root.box1)) {  
arg.\_x = box1.\_x;  
arg.\_y = box1.\_y;  
} else if (arg.hitTest(\_root.box2)) {  
arg.\_x = box2.\_x;  
arg.\_y = box2.\_y;  
} else if (arg.hitTest(\_root.box3)) {  
arg.\_x = box3.\_x;  
arg.\_y = box3.\_y;  
} else if (arg.hitTest(\_root.box4)) {  
arg.\_x = box4.\_x;  
arg.\_y = box4.\_y;  
} else {  
arg.\_x = applex.\_x;  
arg.\_y = appley.\_y;  
arg.\_x = waterx.\_x;  
arg.\_y = watery.\_y;  
}  
}
