6 Replies Latest reply on Jul 7, 2010 11:04 AM by Ned Murphy

    drag and drop target help please

    niamh.omahony11

      Hi! I need a movie clip to play, or go to a frame, or just make  something happen when all the draggable items have been dropped onto the  targets. Can anyone please tell me how to do this based on this code?  Im sure it's pretty basic but I can't figure it out.

      Thanks very much!


      // start points
      // these are the original starting points for the draggers
      // this is where they snap back to if wrong.
      var start1x:Number = ciarahair_movieclip._x;
      var start1y:Number = ciarahair_movieclip._y;
      var start2x:Number = greghair_movieclip._x;
      var start2y:Number = greghair_movieclip._y;
      var start3x:Number = ciaraeyes_movieclip._x;
      var start3y:Number = ciaraeyes_movieclip._y;
      var start4x:Number = gregeyes_movieclip._x;
      var start4y:Number = gregeyes_movieclip._y;
      // allow the movieclips to be dragged by mouse
      // start drags�
      ciarahair_movieclip.onPress = function() {
      startDrag(this);
      };
      greghair_movieclip.onPress = function() {
      startDrag(this);
      };




      gregeyes_movieclip.onPress = function() {
      startDrag(this);
      };

      ciaraeyes_movieclip.onPress = function() {
      startDrag(this);
      };

      // drop them..
      // drag 1 gets dropped on drop1
      // else goes back to start position
      ciarahair_movieclip.onRelease = function() {
      // stop dragging
      this.stopDrag();
      // if correct drop zone
      if (eval(this._droptarget) == dropciarahair_mc) {
      // leave it there
      this._x = dropciarahair_mc._x;
      this._y = dropciarahair_mc._y;
      sound1.gotoAndPlay(2);
      } else {
      // take back to start pos
      this._x = start1x;
      this._y = start1y;
      }
      };



      //drag 2
      greghair_movieclip.onRelease = function() {
      this.stopDrag();
      if (eval(this._droptarget) == dropgreghair_mc) {
      this._x = dropgreghair_mc._x;
      this._y = dropgreghair_mc._y;
      sound1.gotoAndPlay(2);
      } else {
      this._x = start2x;
      this._y = start2y;
      }
      };


      //drag 4
      ciaraeyes_movieclip.onRelease = function() {
      this.stopDrag();
      if (eval(this._droptarget) == dropciaraeyes_mc) {
      this._x = dropciaraeyes_mc._x;
      this._y = dropciaraeyes_mc._y;
      sound1.gotoAndPlay(2);
      } else {
      this._x = start3x;
      this._y = start3y;
      }
      };







      //drag 4
      gregeyes_movieclip.onRelease = function() {
      this.stopDrag();
      if (eval(this._droptarget) == dropgregeyes_mc) {
      this._x = dropgregeyes_mc._x;
      this._y = dropgregeyes_mc._y;
      sound1.gotoAndPlay(2);


      } else {
      this._x = start4x;
      this._y = start4y;
      }
      };


      reset_mc.onRelease = function() {
      gregeyes_movieclip._x = start4x;
      gregeyes_movieclip._y = start4y;
      ciaraeyes_movieclip._x = start3x;
      ciaraeyes_movieclip._y = start3y;
      greghair_movieclip._x = start2x;
      greghair_movieclip._y = start2y;
      ciarahair_movieclip._x = start1x;
      ciarahair_movieclip._y = start1y;
      }