# Question Drag and Drop

**URL:** <https://forum.kirupa.com/t/question-drag-and-drop/327791>\
**Category:** flash\
**Created:** [March 28, 2012, 10:59pm UTC](https://forum.kirupa.com/t/question-drag-and-drop/327791 "2012-03-28T22:59:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![MAGG0T](https://avatars.discourse-cdn.com/v4/letter/m/94ad74/32.png) [@MAGG0T](https://forum.kirupa.com/u/MAGG0T)\
**Post date:** [March 28, 2012, 10:59pm UTC](https://forum.kirupa.com/t/question-drag-and-drop/327791/1 "2012-03-28T22:59:05Z")

</div>

In my drag and drop i have 2 dragable objects and 2 targets.  
It works perfectly on the first scene frame 1 But what i want to do is add all 4 dragable images and targets together in one movie clip but when i add all of them into a single movieclip it stops working i have tried putting the actionscript in the 1st frame of the movieclip but that still didn’t work anyone can help i would be so greatful!

[COLOR=#000000][FONT=verdana]Movieclip’s in file [/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]circle\_mc[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]circle\_mc2[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]target circle[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]target circle2[/FONT][/COLOR]  
[COLOR=#000000][FONT=verdana]im trying to add them all together so i have 1 movieclip on the 1st scene but when i group them all into 1 movieclip it stops working…[/FONT][/COLOR]

> circle\_mc.onPress = function() {startDrag(this);};circle\_mc.onRelease = circle\_mc.onReleaseOutside=function () {stopDrag();if (this.\_droptarget == “/targetCircle”) {this.onTarget = true;\_root.targetCircle.gotoAndStop(2);} else {this.onTarget = false;\_root.targetCircle.gotoAndStop(1);}};//the variables below will store the clips starting positioncircle\_mc.myHomeX=circle\_mc.\_x;circle\_mc.myHomeY=circle\_mc.\_y;//the variables below will store the clips end positioncircle\_mc.myFinalX = 45.6;circle\_mc.myFinalY = 37.0;circle\_mc.onMouseDown = function() {//this variable tells us if the mouse is up or downmousePressed = true;};circle\_mc.onMouseUp = function() {mousePressed = false;};circle\_mc.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 (mousePressed == false && this.onTarget == false) {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 (mousePressed == false && this.onTarget == true) {this.\_x -= (this.\_x-this.myFinalX)/5;this.\_y -= (this.\_y-this.myFinalY)/5;}}; //start dragable image 2 and target  
> circle\_mc2.onPress = function() {startDrag(this);};circle\_mc2.onRelease = circle\_mc2.onReleaseOutside=function () {stopDrag();if (this.\_droptarget == “/targetCircle2”) {this.onTarget = true;\_root.targetCircle2.gotoAndStop(2);} else {this.onTarget = false;\_root.targetCircle2.gotoAndStop(1);}};//the variables below will store the clips starting positioncircle\_mc2.myHomeX=circle\_mc2.\_x;circle\_mc2.myHomeY=circle\_mc2.\_y;//the variables below will store the clips end positioncircle\_mc2.myFinalX = 118.5;circle\_mc2.myFinalY = 37.0;circle\_mc2.onMouseDown = function() {//this variable tells us if the mouse is up or downmousePressed = true;};circle\_mc2.onMouseUp = function() {mousePressed = false;};circle\_mc2.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 (mousePressed == false && this.onTarget == false) {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 (mousePressed == false && this.onTarget == true) {this.\_x -= (this.\_x-this.myFinalX)/5;this.\_y -= (this.\_y-this.myFinalY)/5;}};

iv attached the fla if anyone would like it have a go.
