3 Replies Latest reply on Jun 10, 2006 9:02 AM by Newsgroup_User

    Quiz Help

    Jadeivy
      I have a quiz that I am using which works fine.
      It was based on a 4 answer multiple choice question.

      I want to add capability for true/false.
      (where action script detects the number of XML answer in a node, and hides the last two choices of the 4 choice question. Thus creating a two answer true/flase question).
      -------------------------------------------------------------

      Code before (working):

      if (currentQuestionNumber>quizItems.length)
      gotoAndStop("SummaryScreen");
      var currentQuizItem=quizItems[currentQuestionNumber-1];
      var hasAnswered=false;
      question=currentQuizItem.getQuestion();
      for (var i=1; i<=4; i++)
      {
      _root["answer"+i]=currentQuizItem.getAnswer(i-1);
      }
      var currentQuizItem=quizItems[currentQuestionNumber-1];
      var hasAnswered=false;
      question=currentQuizItem.getQuestion();
      for (var i=1; i<=4; i++)
      {
      _root["answer"+i]=currentQuizItem.getAnswer(i-1);
      }

      stop();

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

      New code (not workign and causing an infinite loop):

      if (currentQuestionNumber>quizItems.length)

      gotoAndStop("SummaryScreen");



      var currentQuizItem=quizItems[currentQuestionNumber-1];

      var hasAnswered=false;

      question=currentQuizItem.getQuestion();

      for (var i=1; i<=currentQuizItem.getNumOfAnswers(); i++)

      {

      _root["answer"+i]=currentQuizItem.getAnswer(i-1);

      _root["answer"+i+"Mark"]._visible=true;

      _root["answer"+i+"Textbox"]._visible=true;

      _root["answer"+i+"Button"]._visible=true;

      }



      for (; i<=4; i++)

      {

      _root["answer"+i+"Mark"]._visible=false;

      _root["answer"+i+"Textbox"]._visible=false;

      _root["answer"+i+"Button"]._visible=false;

      }

      stop();



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



      this.getNumOfAnswers=function()

      {

      return this.answers.length;

      }




      I can't figure out where the loop error is!

      Anyone?
        • 1. Re: Quiz Help
          Level 7
          for (; i<=4; i++) might better be for (var i=1; i<=4; i++)

          --
          Lon Hosford
          www.lonhosford.com
          Flash, Actionscript and Flash Media Server examples:
          http://flashexamples.hosfordusa.com
          May many happy bits flow your way!
          "Jadeivy" <webforumsuser@macromedia.com> wrote in message
          news:e6d1s9$m5u$1@forums.macromedia.com...
          I have a quiz that I am using which works fine.
          It was based on a 4 answer multiple choice question.

          I want to add capability for true/false.
          (where action script detects the number of XML answer in a node, and hides
          the
          last two choices of the 4 choice question. Thus creating a two answer
          true/flase question).
          -------------------------------------------------------------

          Code before (working):

          if (currentQuestionNumber>quizItems.length)
          gotoAndStop("SummaryScreen");
          var currentQuizItem=quizItems[currentQuestionNumber-1];
          var hasAnswered=false;
          question=currentQuizItem.getQuestion();
          for (var i=1; i<=4; i++)
          {
          _root["answer"+i]=currentQuizItem.getAnswer(i-1);
          }
          var currentQuizItem=quizItems[currentQuestionNumber-1];
          var hasAnswered=false;
          question=currentQuizItem.getQuestion();
          for (var i=1; i<=4; i++)
          {
          _root["answer"+i]=currentQuizItem.getAnswer(i-1);
          }

          stop();

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

          New code (not workign and causing an infinite loop):

          if (currentQuestionNumber>quizItems.length)

          gotoAndStop("SummaryScreen");



          var currentQuizItem=quizItems[currentQuestionNumber-1];

          var hasAnswered=false;

          question=currentQuizItem.getQuestion();

          for (var i=1; i<=currentQuizItem.getNumOfAnswers(); i++)

          {

          _root["answer"+i]=currentQuizItem.getAnswer(i-1);

          _root["answer"+i+"Mark"]._visible=true;

          _root["answer"+i+"Textbox"]._visible=true;

          _root["answer"+i+"Button"]._visible=true;

          }



          for (; i<=4; i++)

          {

          _root["answer"+i+"Mark"]._visible=false;

          _root["answer"+i+"Textbox"]._visible=false;

          _root["answer"+i+"Button"]._visible=false;

          }

          stop();



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



          this.getNumOfAnswers=function()

          {

          return this.answers.length;

          }




          I can't figure out where the loop error is!

          Anyone?


          • 2. Re: Quiz Help
            Jadeivy Level 1
            I tried that originally and I lose all functionality.

            I know it's odd that the variable is not defined, however it was in the tutorial I used to create this.

            http://www.permadi.com/tutorial/flashMXQuiz/index3a.html
            • 3. Re: Quiz Help
              Level 7
              That was causing the infinite loop. Could be an error in the online html
              formatting at the publisher's web site. This is a common risk you take
              copying code from web pages that do not have a downloadable tested solution.

              Contact them for a verification.

              --
              Lon Hosford
              www.lonhosford.com
              Flash, Actionscript and Flash Media Server examples:
              http://flashexamples.hosfordusa.com
              May many happy bits flow your way!
              "Jadeivy" <webforumsuser@macromedia.com> wrote in message
              news:e6d6ae$qtl$1@forums.macromedia.com...
              I tried that originally and I lose all functionality.

              I know it's odd that the variable is not defined, however it was in the
              tutorial I used to create this.

              http://www.permadi.com/tutorial/flashMXQuiz/index3a.html