Results 1 to 1 of 1
Thread: Question Drag and Drop
-
March 28th, 2012, 06:59 PM #133Registered User
postsQuestion Drag and Drop
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!
Movieclip's in file
circle_mc
circle_mc2
target circle
target circle2
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..
iv attached the fla if anyone would like it have a go.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.m yHomeY=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_mc 2.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;}};Last edited by MAGG0T; March 28th, 2012 at 08:20 PM.

Reply With Quote

Bookmarks