7 Replies Latest reply on Aug 19, 2014 10:36 AM by kglad

    drag and drop with user feedback

    tmjames_128

      I created a drag and drop game where users drop sections on a map and instantly receive feedback if they are correct or incorrect.  I've got the correct feedback working correctly but I can figure out the incorrect part as it is below nothing happens.  Any help is greatly appreciated


      ------------------------------

       


      stop();

       

       

      _global.counter=1;

      _global.totalquestions=10;

       

       

      Slogan1="Question 1";

      Slogan2="Question 2";

      Slogan3="Question 3";

      Slogan4="Question 4";

      Slogan5="Question 5";

      Slogan6="Question 6";

      Slogan7="Question 7";

      Slogan8="Question 8";

      Slogan9="Question 9";

       

      Answer1="Box_A";

      Answer2="Box_B";

      Answer3="Box_C";

      Answer4="Box_D";

      Answer5="Box_E";

      Answer6="Box_F";

      Answer7="Box_G";

      Answer8="Box_H";

      Answer9="Box_I";

       

      function init(){

      _root.slogan.text=Slogan1;

      _global.answer=Answer1;

      _global.counter++;

      }

       

      function checkAnswer(guess){

      if (guess==_global.answer){

      _root.slogan.text=eval("Slogan"+_global.counter);

      _global.answer=eval("Answer"+_global.counter);

      _global.counter++;

       

      //_root.result.text="You Are Correct";

      feedback("correct");

      eval("_root." + guess)._alpha=70;

      eval("_root." + guess).active=0;

      if (_global.counter > _global.totalquestions){

      _root.complete.text="Quiz Complete";

      _root.slogan.text="Quiz Complete";

        }

       

      }else{

      //_root.result.text="You Are Wrong";

      feedback("incorrect");

        }

      }

       

      init();

       

      function feedback (response){

        _root.correct._visible=0;

        _root.incorrect._visible=0;

        clearInterval (_global.feedTime);

       

         if (response=="correct")

         {_root.correct._visible=1;

           }else{

         _root.incorrect._visible=1;

         }

         _global.feedTime=setInterval (clearFeed, 1000, response);

        

         }

        

      function clearFeed(response){

        eval("_root."+response)._visible=0;

        clearInterval (_global.feedTime);

      }

        • 1. Re: drag and drop with user feedback
          kglad Adobe Community Professional & MVP

          use the trace function to debug.

           

           


          stop();

           

           

          _global.counter=1;

          _global.totalquestions=10;

           

           

          Slogan1="Question 1";

          Slogan2="Question 2";

          Slogan3="Question 3";

          Slogan4="Question 4";

          Slogan5="Question 5";

          Slogan6="Question 6";

          Slogan7="Question 7";

          Slogan8="Question 8";

          Slogan9="Question 9";

           

          Answer1="Box_A";

          Answer2="Box_B";

          Answer3="Box_C";

          Answer4="Box_D";

          Answer5="Box_E";

          Answer6="Box_F";

          Answer7="Box_G";

          Answer8="Box_H";

          Answer9="Box_I";

           

          function init(){

          _root.slogan.text=Slogan1;

          _global.answer=Answer1;

          _global.counter++;

          }

           

          function checkAnswer(guess){

          trace(guess+" "+_global.answer);

          if (guess==_global.answer){

          _root.slogan.text=eval("Slogan"+_global.counter);

          _global.answer=eval("Answer"+_global.counter);

          _global.counter++;

           

          //_root.result.text="You Are Correct";

          feedback("correct");

          eval("_root." + guess)._alpha=70;

          eval("_root." + guess).active=0;

          if (_global.counter > _global.totalquestions){

          _root.complete.text="Quiz Complete";

          _root.slogan.text="Quiz Complete";

            }

           

          }else{

          //_root.result.text="You Are Wrong";

          trace("incorrect");

          feedback("incorrect");

            }

          }

           

          init();

           

          function feedback (response){

            _root.correct._visible=0;

            _root.incorrect._visible=0;

            clearInterval (_global.feedTime);

           

             if (response=="correct")

             {_root.correct._visible=1;

               }else{

          trace("incorrect and code is working")

             _root.incorrect._visible=1;

             }

             _global.feedTime=setInterval (clearFeed, 1000, response);

           

             }

           

          function clearFeed(response){

            eval("_root."+response)._visible=0;

            clearInterval (_global.feedTime);

          }

          • 2. Re: drag and drop with user feedback
            tmjames_128 Level 1

            When I do that this is displayed - Box_A Box_A.  So the correct part is working but something is wrong with the incorrect that I cant seem to figure out.

             


            stop();

             

             

            _global.counter=1;

            _global.totalquestions=10;

             

             

            Slogan1="Question 1";

            Slogan2="Question 2";

            Slogan3="Question 3";

            Slogan4="Question 4";

            Slogan5="Question 5";

            Slogan6="Question 6";

            Slogan7="Question 7";

            Slogan8="Question 8";

            Slogan9="Question 9";

             

             

            Answer1="Box_A";

            Answer2="Box_B";

            Answer3="Box_C";

            Answer4="Box_D";

            Answer5="Box_E";

            Answer6="Box_F";

            Answer7="Box_G";

            Answer8="Box_H";

            Answer9="Box_I";

             

             

             

             

             

             

            function init(){

            _root.slogan.text=Slogan1;

            _global.answer=Answer1;

            _global.counter++;

            }

             

             

            function checkAnswer(guess){

            trace(guess+" "+_global.answer);

            if (guess==_global.answer){

            _root.slogan.text=eval("Slogan"+_global.counter);

            _global.answer=eval("Answer"+_global.counter);

            _global.counter++;

             

             

            //_root.result.text="You Are Correct";

            feedback("correct");

            eval("_root." + guess)._alpha=70;

            eval("_root." + guess).active=0;

            if (_global.counter > _global.totalquestions){

            _root.complete.text="Quiz Complete";

            _root.slogan.text="Quiz Complete";

              }

             

            }else{

            //_root.result.text="You Are Wrong";

            trace("incorrect");

            feedback("incorrect");

              }

            }

             

             

            init();

             

             

            function feedback (response){

              _root.correct._visible=0;

              _root.incorrect._visible=0;

              clearInterval (_global.feedTime);

             

               if (response=="correct")

               {_root.correct._visible=1;

                 }else{

              trace("incorrect and code is working")

               _root.incorrect._visible=1;

               }

               _global.feedTime=setInterval (clearFeed, 1000, response);

              

               }

              

            function clearFeed(response){

              eval("_root."+response)._visible=0;

              clearInterval (_global.feedTime);

            }

            • 3. Re: drag and drop with user feedback
              kglad Adobe Community Professional & MVP

              well, what do you see when you drop an incorrect object?

              • 5. Re: drag and drop with user feedback
                kglad Adobe Community Professional & MVP

                then you're not calling checkAnswer() when you drop an incorrect object.

                 

                what code executes when an object is dropped?

                • 6. Re: drag and drop with user feedback
                  tmjames_128 Level 1

                  This is the code on every object that is dropped, there are 9 of them. 

                   

                   

                  onClipEvent (load) {

                    this.active = 1;

                    origX = this._x;

                    origY = this._y;

                  }

                  onClipEvent (mouseDown) {

                    if (this.hitTest(_root._xmouse, _root._ymouse))

                    {

                   

                   

                   

                   

                    if (this.active == 1)

                    {

                   

                   

                   

                   

                    this.startDrag();

                    }

                    }

                  }

                  onClipEvent (mouseUp){

                    if (this.active == 1)

                    {

                   

                   

                   

                   

                    if (this.hitTest(_root._xmouse, _root._ymouse))

                    {

                   

                   

                       // see if the dropZone conatins the center of this mc

                    if (_parent.dropZone_A.hitTest(this._x, this._y, true))

                    {

                    _root.checkAnswer(this._name);

                    origX = 285.95;

                    origY = 230.00;

                    }

                    }

                    }

                   

                   

                    this._x = origX;

                    this._y = origY;

                    this.stopDrag();

                   

                   

                  }

                  • 7. Re: drag and drop with user feedback
                    kglad Adobe Community Professional & MVP

                    that's not good coding.

                     

                    but the problem is probably,

                     

                      if (_parent.dropZone_A.hitTest(this._x, this._y, true))