3 Replies Latest reply on Nov 9, 2011 7:01 AM by paddy1921

    multiple dropzones possible for a drag & drop item - show answers option

    paddy1921

      I have a drag & drop activity where 3 of the drags can go into 1 of 3 possible dropzones and be counted as correct. On clicking 'Submit', if only some are placed correctly, there's a 'Show me' option - this is the bit I can't do:

      if some of those with more than 1 possible answer are correct, I don't know how to check which dropzones are free to place the remainder in.

      My code for the first bit, checking the hitTest is ok:

       

      for (var i:Number = 0; i<aLabels.length; i++) {

      //3 drag items have 3 poss dropzones:

              for (var t:Number = 0; t<aNewCorrectDZ[i].length; t++) {

                  //IF ITEM IS DROPPED ON ANY DROPZONE:

                  if (clip.hitTest(content1[aNewCorrectDZ[clip.ID][t]])) {

                      placedCorrectly = true;

                      //RECORD WHICH ZONE IT'S DROPPED ON, TO BE MARKED AT THE END:

                      dzTaken = aNewCorrectDZ[clip.ID][t];

                      break;

                  } else ...............

       

      Have tried variations of this for days! Any ideas?

        • 1. Re: multiple dropzones possible for a drag & drop item - show answers option
          Ned Murphy Adobe Community Professional & MVP

          It is not clear to me what your problem is, but if you are saying that you want to be able to determine if a target already has something on it, then just assign an "occupied" variable (name it as you pleae) to each target and when a drop is successfully made there, assign that target's "occupied" variable as being true.

          1 person found this helpful
          • 2. Re: multiple dropzones possible for a drag & drop item - show answers option
            paddy1921 Level 1

            thanks for the idea, that definitely helps with part of it. I'll implement that idea and will probably need to come back to you when I have some 'cleaner' code to clarify the question. Cheers.

            • 3. Re: multiple dropzones possible for a drag & drop item - show answers option
              paddy1921 Level 1

              Here are clearer details (I hope) of the problem:

              My drag & drop activity has 11 draggable items and 11 dropzones. 3 of the draggable items are correct if dropped in any 1 of 3 different dropzones (e.g. dragItem 1, 2 and 3 can be dropped in dropZone 1, 6 or 7); the other draggable items only have 1 possible correct dropzone.

              So, a user drags them so all dropZones are occupied but some are placed incorrectly & marked as such, e.g. dragItem 2 & 3 (the ones with more than 1 correct answer) and dragItem 4 & 5 are wrong. A 'Show me' button is clicked & uses the code below. Let's say the correctly placed dragItem 1 happens to occupy dropZone7, therefore, on 'Show me' - dragItem 2 & 3 can only go into dropZone 1 & 6 - this code sends them all to dropZone 7

               

              for (var i:Number = 0; i<aLabels.length; i++) {

                                      …….

              // 'aNewCorrectDZ' is the array holding the correct answers

                                      for (var t:Number = 0; t<aNewCorrectDZ[i].length; t++) {

                                                  //IDENTIFY THOSE DRAGITEMs WRONGLY PLACED

                                                  if (aLabels[i][2] == false) {

                                                              //SPECIFY CO-ORDS OF DROPZONE WHICH IS THE CORRECT ANSWER

                                                              var newX = content1[aNewCorrectDZ[i][t]]._x;

                                                              var newY = content1[aNewCorrectDZ[i][t]]._y;

                                                              //NOW SLIDE DRAGITEM INTO CORRECT PLACE

                                                              new Tween(content1[dragItem], "_x", Regular.easeIn, currX, newX, 1, true);
                new Tween(content1[dragItem], "_y", Regular.easeIn, currY, newY, 1, true);

                                                  }

                                      }

                          }

               

              Obviously   'aNewCorrectDZ[i][t]' for dragItems 2 & 3 in this example reads: 'dropZone1,'dropZone6,'dropZone7' 

              Can anyone help show me how to do this please? I've tried for days …