3 Replies Latest reply on Sep 28, 2011 2:41 PM by eg@CDW

    AS2 Drag and Drop Interaction help

    eg@CDW Level 1

      I am trying to create a reusable template for a drag and drop interaction.


      There are 7 drag objects, 7 targets.

      Based on a scenario we develop (which of the 7 services [drag objects] are the best solution, for example), I would like to create interactions where some of the drag drop combinations are correct answers and dragging/dropping other combinations would result in an "incorrect" answer.


      I am having issues with designating the correct and incorrect responses in the AS code, as well as how to provide the positive (correct answers) and negative (incorrect answers) feedback after a submit button is selected.


      Additionaly, I have a reset button that does not function the way I expected - move the drag objects back to the start position and allow the user to resubmit an answer.


      I am using Flash CS5, but need to use AS2 as the swf file is going to be inserted into an Articulate Presenter project (Articulate does not support AS3 yet).


      Thank you for any assistance or suggestions!


      Source file: https://www.dropbox.com/home/AS2%20D&D#:::68035214


      Current AS2 code:


      function dragSetup(clip, targ) {

      clip.onPress = function() {




      clip.onRelease = clip.onReleaseOutside=function () {



      if (eval(this._droptarget) == targ) {

      this.onTarget = true;


      } else {

      this.onTarget = false;




      //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;













      //this code controls the reset button function and returns all of the drag objects to the start position.

      resetBtn.onRelease = function (){




      drag1._x = drag1.myHomeX;

      drag1._y = drag1.myHomeY;




      drag2._x = drag2.myHomeX;

      drag2._y = drag2.myHomeY;




      drag3._x = drag3.myHomeX;

      drag3._y = drag3.myHomeY;




      drag4._x = drag4.myHomeX;

      drag4._y = drag4.myHomeY;




      drag5._x = drag5.myHomeX;

      drag5._y = drag5.myHomeY;




      drag6._x = drag6.myHomeX;

      drag6._y = drag6.myHomeY;




      drag7._x = drag7.myHomeX;

      drag7._y = drag7.myHomeY;




      //This code controls the submitBtn and feedback for a correct and incorrect answer

      var groupID:Array = [0,0];

      var incorrectFeedback:String = "That isn't correct.";

      var correctFeedback:String = "Excellent good work.";

      var answerGroup:Array =  [











      //Enable all the stage items

      resetBtn.onRelease = function()






      submitBtn.onRelease = function()





                          feedbackTxt.text = correctFeedback;




                          feedbackTxt.text = incorrectFeedback;