9 Replies Latest reply on Oct 19, 2011 10:16 AM by kglad

    Feedback Text for a Drag and Drop Interaction help

    eg@CDW

      I've developed an drag/drop interaction which works well, the issue is with the behavior of the submit reset buttons.

       

      If the "correct" drag objects are on the "correct" target - no issues

       

      The problem is if an "incorrect" drag/drop combination is selected, the "incorrect" feedback text displays and the reset button moves all drag object to the start position, but once the "correct" drag drop combination is submitted, the "incorrect" feedback text displays.

       

      The fla can be viewed here: skydrive.live.com/?cid=bb539b6eff0afbf5&sc=documents&uc=1&id=BB539B6 EFF0AFBF5%21114#

       

      Thanks in advance for any assistance/suggestions you can provide and for taking the time to read this post

       

       

      The relevant code is:

       

      On Frame 1:

       

       

      ActionScript Code:

       

       

      function dragSetup(clip, targ) { clip.onPress = function() { startDrag(this); this.beingDragged=true; }; clip.onRelease = clip.onReleaseOutside=function () { stopDrag(); this.beingDragged=false; if (eval(this._droptarget) == targ) { this.onTarget = true; _root.targ.gotoAndStop(2); } else { this.onTarget = false; _root.targ.gotoAndStop(1); } }; //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 drag object 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; } }; } dragSetup(drag1,drop1); dragSetup(drag2,drop2); dragSetup(drag3,drop3); dragSetup(drag4,drop4); dragSetup(drag5,drop5); dragSetup(drag6,drop6); dragSetup(drag7,drop7);

       

       

       

      on the submitBtn:

       

       

      ActionScript Code:

       

       

      on (press) {     if ((_root.drag1._droptarget == "/drop1") &&         (_root.drag2._droptarget == "/drop2") &&         (_root.drag3._droptarget == "/drop3") &&         (_root.drag4._droptarget != "/drop4") &&         (_root.drag5._droptarget != "/drop5") &&         (_root.drag6._droptarget != "/drop6") &&         (_root.drag7._droptarget != "/drop7"))     {         {             resetBtn.enabled = false;         };         {             feedbackTxt = "Yes, hardware installation, asset tagging and imaging are the best services to recommend to help your customer meet her deadline.";         };         {             drag1.enabled = false;             drag2.enabled = false;             drag3.enabled = false;             drag4.enabled = false;             drag5.enabled = false;             drag6.enabled = false;             drag7.enabled = false;         };     }     else     {         feedbackTxt = "Not quite.  At least one of services you chose isn't the best recommendation, or you did not chose all of the correct services.  Consider your customers business needs, click Reset and try again.";         gotoAndPlay("Scene 1", 1);     } }

       

       

      on the resetBtn:

       

       

      ActionScript Code:

       

       

      //this code controls the reset button function and returns all of the drag objects to the start position. on(Press) {  drag1.onTarget=false; drag1._x = drag1.myHomeX; drag1._y = drag1.myHomeY;  drag2.onTarget=false; drag2._x = drag2.myHomeX; drag2._y = drag2.myHomeY;  drag3.onTarget=false; drag3._x = drag3.myHomeX; drag3._y = drag3.myHomeY;  drag4.onTarget=false; drag4._x = drag4.myHomeX; drag4._y = drag4.myHomeY;  drag5.onTarget=false; drag5._x = drag5.myHomeX; drag5._y = drag5.myHomeY;  drag6.onTarget=false; drag6._x = drag6.myHomeX; drag6._y = drag6.myHomeY;  drag7.onTarget=false; drag7._x = drag7.myHomeX; drag7._y = drag7.myHomeY;  feedbackTxt = ""}

       

        • 1. Re: Feedback Text for a Drag and Drop Interaction help
          kglad Adobe Community Professional & MVP

          it's nearly impossible to read your code.  copy and paste (ctrl-v) your code.

          • 2. Re: Feedback Text for a Drag and Drop Interaction help
            eg@CDW Level 1

            Apologies abt the code format - here it is reposted so it can be read:

             

            I've developed an drag/drop interaction which works well, the issue is with the behavior of the submit reset buttons.

             

            If the "correct" drag objects are on the "correct" target - no issues

             

            The problem is if an "incorrect" drag/drop combination is selected, the "incorrect" feedback text displays and the reset button moves all drag object to the start position, but once the "correct" drag drop combination is submitted, the "incorrect" feedback text displays.

             

            The fla can be viewed here: skydrive.live.com/?cid=bb539b6eff0afbf5&sc=documents&uc=1&id=BB539B6 EFF0AFBF5%21114#

             

            Thanks in advance for any assistance/suggestions you can provide and for taking the time to read this post

             

             

            The relevant code is:

             

            On Frame 1:

             

            function dragSetup(clip, targ) {

            clip.onPress = function() {

            startDrag(this);

            this.beingDragged=true;

            };

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

            stopDrag();

            this.beingDragged=false;

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

            this.onTarget = true;

            _root.targ.gotoAndStop(2);

            } else {

            this.onTarget = false;

            _root.targ.gotoAndStop(1);

            }

            };

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

            }

            };

            }

            dragSetup(drag1,drop1);

            dragSetup(drag2,drop2);

            dragSetup(drag3,drop3);

            dragSetup(drag4,drop4);

            dragSetup(drag5,drop5);

            dragSetup(drag6,drop6);

            dragSetup(drag7,drop7);

             

             


             

            on the submitBtn:

             

            on (press) {

                      if ((_root.drag1._droptarget == "/drop1") &&

                                (_root.drag2._droptarget == "/drop2") &&

                                (_root.drag3._droptarget == "/drop3") &&

                                (_root.drag4._droptarget != "/drop4") &&

                                (_root.drag5._droptarget != "/drop5") &&

                                (_root.drag6._droptarget != "/drop6") &&

                                (_root.drag7._droptarget != "/drop7"))

                      {

                                {

                                          resetBtn.enabled = false;

                                };

                                {

                                          feedbackTxt = "Yes, hardware installation, asset tagging and imaging are the best services to recommend to help your customer meet her deadline.";

                                };

                                {

                                          drag1.enabled = false;

                                          drag2.enabled = false;

                                          drag3.enabled = false;

                                          drag4.enabled = false;

                                          drag5.enabled = false;

                                          drag6.enabled = false;

                                          drag7.enabled = false;

                                };

                      }

                      else

                      {

                                feedbackTxt = "Not quite.  At least one of services you chose isn't the best recommendation, or you did not chose all of the correct services.  Consider your customers business needs, click Reset and try again.";

                                gotoAndPlay("Scene 1", 1);

                      }

            }

             

             

            on the resetBtn:

             

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

            on(Press) {

             

             

            drag1.onTarget=false;

            drag1._x = drag1.myHomeX;

            drag1._y = drag1.myHomeY;

             

             

            drag2.onTarget=false;

            drag2._x = drag2.myHomeX;

            drag2._y = drag2.myHomeY;

             

             

            drag3.onTarget=false;

            drag3._x = drag3.myHomeX;

            drag3._y = drag3.myHomeY;

             

             

            drag4.onTarget=false;

            drag4._x = drag4.myHomeX;

            drag4._y = drag4.myHomeY;

             

             

            drag5.onTarget=false;

            drag5._x = drag5.myHomeX;

            drag5._y = drag5.myHomeY;

             

             

            drag6.onTarget=false;

            drag6._x = drag6.myHomeX;

            drag6._y = drag6.myHomeY;

             

             

            drag7.onTarget=false;

            drag7._x = drag7.myHomeX;

            drag7._y = drag7.myHomeY;

             

             

            feedbackTxt = "";

             

             

            }

             

             

            Thanks again!


            • 3. Re: Feedback Text for a Drag and Drop Interaction help
              kglad Adobe Community Professional & MVP

              use:

               

               

              on the submitBtn:

               

              on (press) {

                        if (_root.drag1.onTarget&&_root.drag2.onTarget&&etc){

               

                                            resetBtn.enabled = false;

               

               

                                            feedbackTxt = "Yes, hardware installation, asset tagging and imaging are the best services to recommend to help your customer meet her deadline.";

               

               

                                            drag1.enabled = false;

                                            drag2.enabled = false;

                                            drag3.enabled = false;

                                            drag4.enabled = false;

                                            drag5.enabled = false;

                                            drag6.enabled = false;

                                            drag7.enabled = false;

               

                        }

                        else

                        {

                                  feedbackTxt = "Not quite.  At least one of services you chose isn't the best recommendation, or you did not chose all of the correct services.  Consider your customers business needs, click Reset and try again.";

                                  gotoAndPlay("Scene 1", 1);  // <- you shouldn't use scenes for navigation in as2.  label that frame and use the goto method/not function:  _root.gotoAndPlay("scene1_frame1");  // for example

                        }

              }

               

               

              1 person found this helpful
              • 4. Re: Feedback Text for a Drag and Drop Interaction help
                eg@CDW Level 1

                Thanks for the suggestion, I made those updates and everything runs fine.

                 

                This issue still remains though.

                 

                For this interaction, the correct response is drag1 on drop1, drag 2 on drop 2, drag 3 on drop 3.

                 

                If if first submit that combination the correct answer feedback text displays

                 

                BUT

                 

                if I submit a wrong answer, say, drag 1 on drop 1 and drag 4 on drop 4 - it does show the incorrect feedback text - I hit reset and all drag obj move back to the starting position.

                 

                THEN if I submit the correct response (after submitting an incorrect one) the Incorrect feedback text displays again - even though it meets the criteria of the IF statement for a correct answer.

                • 5. Re: Feedback Text for a Drag and Drop Interaction help
                  kglad Adobe Community Professional & MVP

                  what's _root.targ?  you're not resetting that.

                  • 6. Re: Feedback Text for a Drag and Drop Interaction help
                    eg@CDW Level 1

                    misinterpreted your suggestion before - I now have -

                     

                    on (press) {

                              if(_root.drag1.onTarget && _root.drag2.onTarget && _root.drag3.onTarget){

                     

                     

                    This works with on minor exception:

                     

                    If I submit the correct answer (drag1 on drop 1, drag2 on drop 2 and drag 3 on drop 3)  AND include one of the incorrect responses, drag5 on drop5 for example, it is displaying the correct feedback text.

                     

                    So it meets the if statement criteria as written, do I need to include the "not on Target" in the if statement?

                    • 7. Re: Feedback Text for a Drag and Drop Interaction help
                      kglad Adobe Community Professional & MVP

                      include all your onTarget's in the if-statement, not just the 3 of them.

                      • 8. Re: Feedback Text for a Drag and Drop Interaction help
                        eg@CDW Level 1

                        OK - I got it THANK YOU

                         

                        on (press) {

                                  if(_root.drag1.onTarget && _root.drag2.onTarget && _root.drag3.onTarget && !_root.drag4.onTarget && !_root.drag5.onTarget && !_root.drag6.onTarget && !_root.drag7.onTarget){