Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.

Cheers,
Kirupa

Results 1 to 1 of 1

Thread: Question Drag and Drop

  1. #1

    Question 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..

    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;}};
    iv attached the fla if anyone would like it have a go.
    Attached Files Attached Files
    Last edited by MAGG0T; March 28th, 2012 at 08:20 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012