6 Replies Latest reply on Aug 21, 2013 3:00 PM by Ned Murphy

    Problem with quiz results.

    EdWeKmon

      Hey guys, i have a problem with a quiz that i need to do, i've been using this template: http://www.permadi.com/tutorial/flashMXQuiz/index.html

      But what i need and it doesnt include is how to put a message at the end of the game which tells you that you won or lost depending if you had at least two questions right or less than two right.

      I´ve been searching and have not found any code that i could just add to my ActionScript.

       

      I also have been trying with variables like this:

       

      if(numofQuestionsAnsweredCorrectly>=2){gotoAndPlay(3)}

      else

      {gotoAndPlay(6)}

       

      ..and stuff like that. I'm sorry if that's completely wrong..I'm just starting to learn.

       

      I hope anybody can help me with this.

       

      Thanks

        • 1. Re: Problem with quiz results.
          Ned Murphy Adobe Community Professional & MVP

          The little bit of code that you showed should work, assuming those are the places you wish to go to.  I can't say if you would want to use gotoAndStop instead of gotoAndPlay, but what you show should work.

           

          How does this code get initiated?  (buitton click, some value sensing, end of quiz processing, etc?)

          1 person found this helpful
          • 2. Re: Problem with quiz results.
            sinious Most Valuable Participant

            Page 3 of the tutorial shows you the SummaryScreen. They calculate the percent correct there:

             

            userScore=(numOfQuestionsAnsweredCorrectly * 100) / (numOfQuestionsAnsweredIncorrectly + numOfQuestionsAnsweredCorrectly);

             

            It's right there you should stick your code to change to the frame you desire. Make sure you're changing the correct clips playhead.

             

            Do note they're using a lot of frame labels (and they're using flash player 6 with some ancient ActionScript 1.0 coding). There's a chance this quiz won't work in the future. Even ActionScript 2.0 has been depreciated and is currently unsupported by the latest version, Flash CC. It doesn't mean the browser plugin doesn't support it but eventually it may. It's long overdue..

             

            For the 1.0 code though, at the point I mentioned you should be able to do it with what you have (if you want to switch the main timeline to those frames via _root.

             

            if (numofQuestionsAnsweredCorrectly >= 2)

            {

                      _root.gotoAndPlay(3)

            }

            else

            {

                      _root.gotoAndPlay(6)

            }

             

            If you want "some other" clip to move to that frame then add the instance name after _root, e.g. _root.myClip.gotoAndPlay(3);, etc..

            1 person found this helpful
            • 3. Re: Problem with quiz results.
              EdWeKmon Level 1

              Thank you so much guys for answering this quickly!! I got the answer correctly thanks in part to Ned Murphy for telling that my code was correct. I feel a little dumb because while i wrote it correctly here, that actually was a mistake, you see, i had a couple of frames tagged as win or lose and instead of the frame number i had been writing their names as in {gotoAndPlay("win")}  but i wrote it from memory and did not realize i had just changed it. I realized this before sinious answered but I'll check your tutorial anyway.

               

              Thanks a lot.

              • 4. Re: Problem with quiz results.
                sinious Most Valuable Participant

                Glad you got it working, you're welcome and good luck!

                • 5. Re: Problem with quiz results.
                  EdWeKmon Level 1

                  Thank you so much guys for answering this quickly!! I got the answer correctly thanks in part to Ned Murphy for telling that my code was correct. I feel a little dumb because while i wrote it correctly here, that actually was a mistake, you see, i had a couple of frames tagged as win or lose and instead of the frame number i had been writing their names as in {gotoAndPlay("win")}  but i wrote it from memory and did not realize i had just changed it. I realized this before sinious answered but I'll check your tutorial anyway.

                   

                  Thanks a lot.

                  • 6. Re: Problem with quiz results.
                    Ned Murphy Adobe Community Professional & MVP

                    You're welcome