# Drag and drop interface - need help

**URL:** <https://forum.kirupa.com/t/drag-and-drop-interface-need-help/288511>\
**Category:** flash\
**Created:** [May 17, 2009, 9:19am UTC](https://forum.kirupa.com/t/drag-and-drop-interface-need-help/288511 "2009-05-17T09:19:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![danwangkw](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@danwangkw](https://forum.kirupa.com/u/danwangkw)\
**Post date:** [May 17, 2009, 9:19am UTC](https://forum.kirupa.com/t/drag-and-drop-interface-need-help/288511/1 "2009-05-17T09:19:15Z")

</div>

With reference to this [**.FLA**](http://www.hed.swinburne.edu.au/design/tutorials/flash/how-to-drag-and-drop-in-flash/drag_n_drop_multiple.zip) and the actionscript which resides within:

> 

function dragSetup(clip, targ) {  
clip.onPress = function() {  
startDrag(this);  
this.beingDragged=true;  
};  
clip.onRelease = clip.onReleaseOutside=function () {  
stopDrag();  
this.beingDragged=false;  
if (eval(this.\_droptarget) == targ) {  
this.onTarget = true;  
\_root.targ.gotoAndStop(2);  
} else {  
this.onTarget = false;  
\_root.targ.gotoAndStop(1);  
}  
};  
//the variables below will store the clips starting position  
clip.myHomeX = clip.\_x;  
clip.myHomeY = clip.\_y;  
//the variables below will store the clips end position  
clip.myFinalX = targ.\_x;  
clip.myFinalY = targ.\_y;  
clip.onEnterFrame = function() {  
//all these actions basically just say “if the mouse is up (in other words - the clip is not being dragged)  
// then move the MC back to its original starting point (with a smooth motion)”  
if (!this.beingDragged && !this.onTarget) {  
this.\_x -= (this.\_x-this.myHomeX)/5;  
this.\_y -= (this.\_y-this.myHomeY)/5;  
//if the circle is dropped on any part of the target it slides to the center of the target  
} else if (!this.beingDragged && this.onTarget) {  
this.\_x -= (this.\_x-this.myFinalX)/5;  
this.\_y -= (this.\_y-this.myFinalY)/5;  
}  
};  
}

dragSetup(circle\_mc,targetCircle);  
dragSetup(circle2\_mc,targetCircle2);

Here’s what I’am trying to achieve and I sincerely seek assistance on how to edit the above actionscript to accomplish it:

**Scenario**

Flash has a classroom scene - three slides (or draggable objects), a slide projector (droptarget) and a screen on the wall. All three objects share the same droptarget.

A movieclip (info\_mc) with four labels (each containing different information for the corresponding slide dragged onto droptarget) - ‘reset’, ‘slide1info’, ‘slide2info’ and ‘slide3info’ is positioned at the screen area. Default to ‘reset’ (empty frame) since nothing has been dragged to the droptarget when the swf loads.

If the user drags an slide1 onto the droptarget, the movieclip at the screen area will jump to the corresponding frame label

info\_mc.gotoAndStop(“slide1info”);

But the droptarget can only accomodate one object at a time. When the user drags slide2 over the droptarget where slide1 already resides, slide1 will move back to its original position.

And if the user drags a slide out of the droptarget (i.e. nothing at the droptarget), info\_mc will gotoAndStop (“reset”).

Any insight will be greatly appreciated.

Rgds,  
Dan
