12 Replies Latest reply on Mar 4, 2009 10:42 AM by Ned Murphy

    Flash quiz

    lackysingh
      Hi I am trying to create a flash quiz using Orielly's ActionScript for Flash MX: The Definitive Guide, 2nd Edition. However i can't get mine to work?? So basically i can't work out what i'm doing wrong is there anything wrong with this as?
        • 1. Flash quiz
          Ned Murphy Adobe Community Professional & MVP
          The code iteself looks correct, although if it all exists in the same place it is not going to play out as it is likely intended to. How/where do you implement it as far as the timeline goes? Where are the buttons located with respect to what you are calling the _parent? Also, describe how it doesn't work.
          • 2. Re: Flash quiz
            lackysingh Level 1
            quote:

            Originally posted by: NedWebs
            The code iteself looks correct, although if it all exists in the same place it is not going to play out as it is likely intended to. How/where do you implement it as far as the timeline goes? Where are the buttons located with respect to what you are calling the _parent? Also, describe how it doesn't work.


            I have seven layers
            scripts
            labels
            quiz end
            question 2
            question 1
            choice buttons
            housing

            this script sits in frame 1 of the scripts layer. The buttons sit on frame one of the choice buttons layer. When i say it doesn't work, the quiz opens to question 1 but when you click either of the buttons it takes you nowhere but it should go to frame "q2"
            • 3. Re: Flash quiz
              Ned Murphy Adobe Community Professional & MVP
              If that code is all in the same place, then you are starting off with answering question 2. Your first group of onRelease assignments are overwritten by your second set.

              If your buttons are not inside a movieclip of their own, then you do not use the _parent reference. If that code is in the maintimeline, then the function's inner code could be (though you can still add "this." to the front)...

              q1answer = 1;
              gotoAndStop("q2");
              • 4. Re: Flash quiz
                lackysingh Level 1
                quote:

                Originally posted by: NedWebs
                If that code is all in the same place, then you are starting off with answering question 2. Your first group of onRelease assignments are overwritten by your second set.

                If your buttons are not inside a movieclip of their own, then you do not use the _parent reference. If that code is in the maintimeline, then the function's inner code could be (though you can still add "this." to the front)...

                q1answer = 1;
                gotoAndStop("q2");



                Hi i've removed the _parent reference and it still doesn't work. Is there anyway I can zip the .fla for you to have a look at?
                • 5. Flash quiz
                  Ned Murphy Adobe Community Professional & MVP
                  I'd rather try to help you solve it, otherwise you are not going to learn much. Struggling to solve something is often the best way of learning.

                  First you need to get rid of some of that code. If all of those on release function are in the same frame, then the second half of them have to be moved to the frame where "q2" is.

                  Next, you need to make sure you have given the instance names you use in the code to your buttons via the properties panel. Instance names are NOT the names you used in the library for the buttons, though they could be if you assign them to be the same.

                  Lastly, you should use the trace() function. It is a handy tool for troubleshooting code. You can use it to see where something stops working as well as to see the values of things.

                  In your first button's function, change it to add a trace statement (you can add as many as you need wherever you need them):

                  // Code executed when button 1 is pressed.
                  choice_1btn.onRelease = function () {

                  trace("Choice 1 selected");

                  q1answer = 1;
                  gotoAndStop("q2");
                  };


                  If you do not see "Choice 1 selected" appear in the output panel after you click the button, you know there is something wrong with how you've implemented that button.

                  You could add another trace statement in the actions frame where "q2" is to let you know if you ever got there.

                  trace("Arrived at q2");
                  trace(q1answer);


                  And it would make it easier for me to read your postings and help you if you do not quote what I say... I know what I said, and can refer back to it if need be. It makes it hard to find where you might be saying something.
                  • 6. Re: Flash quiz
                    lackysingh Level 1
                    Hi i've tried all the above and i get nothing in the output window. Any ideas where i could be going wrong?
                    • 7. Re: Flash quiz
                      Ned Murphy Adobe Community Professional & MVP
                      If you understood what I said regarding trace statements, you know as much as I do at the moment... your button is not working.

                      Try creating a new file, put a button in it, and assign it an instance name. For that button's function, only place a trace() call inside it to indicate you processed the function.

                      Get that working first.
                      • 8. Re: Flash quiz
                        kingmarsh
                        Once I used code to create Flash quiz for me, now I give up. Alternatively, you could create a flash quiz with free quiz template in Adobe Flash
                        • 9. Re: Flash quiz
                          lackysingh Level 1
                          Hi thanks for all your help, i tried creating a new file and created a new button from scratch as opposed to using a button from the library. This was what the problem was. Now it is working just fine and i will extend this to a fully functioning quiz. One more question if you don't mind.

                          The quiz has a counter that adds up scores. It displays a text mesage telling the user their score. How would i get the text to display in the font size, colour and type that i want?

                          • 10. Re: Flash quiz
                            Ned Murphy Adobe Community Professional & MVP
                            Look into the TextFormat class. Apply a text format to the textfield after you have placed the text into it.

                            Another option is to just use a dynamic textfield manually placed on the stage and assign those properties via the properties panel
                            • 11. Re: Flash quiz
                              lackysingh Level 1
                              NedWebs, thanks for your help, i've done a search for font formatting classes and functions. I've managed to change color, weight size, position etc.. feeling very smug at the moment, thanks for your assistance.
                              • 12. Re: Flash quiz
                                Ned Murphy Adobe Community Professional & MVP
                                You're welcome.