4 Replies Latest reply on Jul 13, 2010 1:41 PM by Ned Murphy

    Flash Quiz need help with actionscript

    Riff88 Level 1


      hallo,

       

      I made a quiz in flash with Four Pages:

       

      1. "Welcome to quiz" etc. with a GO TO QUIZ button.
      2. The Actual Quiz with two possible answers
      3. correct answer
      4. incorrect answer with link to start over.

       

      I added the following script to jump between pages:

       

      on(release){
      gotoAndPlay(pagenumber)
      }

       

      it works perfectly. But...

       

      I want to add multiple quizzes which i will figure out on my own, but I want to add some sort of counter, which at the end of the quiz will give a percentage or a count eg. 7/10 - 70% Congrats! or something like that.

       

      Does anyone have any idea how I would write that script?

       

      I'm a total Flash newbie by the way!

       

      Thanks so much!

        • 1. Re: Flash Quiz need help with actionscript
          Ned Murphy Adobe Community Professional & MVP

          Create an actions layer that extends through all your pages and define a score variable...

           

          var score = 0;

           

          Maybe for each correct answer you increment the value by 1...

           

          score += 1;

           

          When you get to the end or wherever, you have a textfield and you use the score value in it in some way...

           

          tField.text = "You answered "+score+" out 10 correctly";

          • 2. Re: Flash Quiz need help with actionscript
            Riff88 Level 1

            Thanks Ned, as kind and helpful as always!

             

            I will give it a go and report back!

            • 3. Re: Flash Quiz need help with actionscript
              Riff88 Level 1

              Hi, thanks Ned,

               

              I managed to do it!

               

              I put on the first frame:

               

               

               

              stop();
              score = 0;


              Then on each of the pages to move:

               

              on(release){
              gotoAndStop(pagenumber);
              }

               

               

               

               

              on the "correct" buttons: (If you click the correct button the script counts it for you)

               

               

               

              on(release){
              gotoAndStop(pagenumber);
              score = score+1;
              }

               

               

               

              On the last frame I made a "score" and "percent" variable with dynamic text box and on the last frame I put the actionscript:

               

              percent = score*20 (the twenty being five questions 5 x 20 = 100%)

               

              So, it's all good, thank you. But I want to get a little cheeky here...

               

              I want to add a sort of highscore box which will let users put in their name and let their score be automatically put in next to the name. Is this possible?

               

              Thanks a bunch, Ned!

              • 4. Re: Flash Quiz need help with actionscript
                Ned Murphy Adobe Community Professional & MVP

                It's possible, but you'll have to get more than just cheeky to do it if you intend for that data to be saved somewhere and recovered.  You need to look into working with databases/files and server side processing scripts (like php).

                 

                Here's a link to a video tutorial that will give you an idea of what you will need to learn about.

                 

                http://www.gotoandlearn.com/play?id=20

                1 person found this helpful