9 Replies Latest reply on Jan 11, 2009 4:29 PM by andyulrika_is_back

    Need Help Disabling Button

    andyulrika_is_back Level 1
      Hello

      I'm having mega problems with the following script. Here's what I'm trying to do:

      I have a multiple choice quiz - There are 4 buttons when clicked on will reveal a tick or cross depending if the answer is correct or not. Fine, all working!

      However, I can't work out how to disable any more clicking which is affecting the final score.

      Can someone please help and show me how to deactivate any more clicks on the script.

      Would it be possible for you to edit the script.

      Many thanks in advance.

      Andy
        • 1. Re: Need Help Disabling Button
          Level 7
          Basically, you need to add a flag to your mouseUp script, so that it
          only does anything if the question has not yet been answered. A property
          such a pQuestionAnswered that starts out false, and gets set to true.

          You are on the right track with the way you are building you behaviors,
          but it seems like it could be simplified a bit. Do all of the ticks and
          checks show regardless of which answer the user selects?

          I think I would separate the behavior that changes the button state (on
          or off) from the code that displays the ticks and checks. On mouseUp you
          can send a message to all sprites. The two behaviors can react
          differently to the the same message. Something like this

          http://bellsouthpwp2.net/d/g/dgcraddock/question.zip
          • 2. Re: Need Help Disabling Button
            andyulrika_is_back Level 1
            Hi Dave

            Thanks for your response. I didn't get a chance to look at your zip file because I couldn't open it.

            Do all of the ticks and checks show regardless of which answer the user selects?

            Yes, they display which is the correct answer, along with the other 3 wrong answers - This is the way I would like the results displayed.

            Is there any place in my code I could add something along the lines of if a question has been answered then disable any more functionality?

            Thanks

            Andy
            • 3. Re: Need Help Disabling Button
              andyulrika_is_back Level 1
              Hi Dave

              I managed to open your zip file...It just downloaded very fast, hence I didn't think it was there!

              Anyway, what you've created is very smart! I wish I had started this way - I have hundreds of multiple choice questions written in 'my' way...so would be a daunting and very time consuming method to change at such a late stage in the game.

              I'm going to see if I can work out how to integrate your code into mine - I'm not at all confident!

              Thanks

              Andy
              • 4. Re: Need Help Disabling Button
                Level 7
                OK try this

                1) add another property
                property pQuestionAnswered

                2) add this to your beginSprite handler

                pQuestionAnswered = FALSE

                3) Modifying your mouseUp handler


                on mouseUp me
                if pNotQuestionAnswered then
                pNotQuestionAnswered = TRUE
                -- followed by the rest of your code
                end if
                end
                • 5. Re: Need Help Disabling Button
                  Level 7
                  oops...

                  on mouseUp me
                  if not pQuestionAnswered then


                  Dave C wrote:
                  > OK try this
                  >
                  > 1) add another property
                  > property pQuestionAnswered
                  >
                  > 2) add this to your beginSprite handler
                  >
                  > pQuestionAnswered = FALSE
                  >
                  > 3) Modifying your mouseUp handler
                  >
                  >
                  > on mouseUp me
                  > if pNotQuestionAnswered then
                  > pNotQuestionAnswered = TRUE
                  > -- followed by the rest of your code
                  > end if
                  > end
                  • 6. Re: Need Help Disabling Button
                    Level 7
                    one more time

                    on mouseUp me
                    if Not pQuestionAnswered then
                    pQuestionAnswered = TRUE
                    • 7. Re: Need Help Disabling Button
                      andyulrika_is_back Level 1
                      Hi Dave

                      Thanks for the replies. I've added your code and this is what happens...

                      If I click on the correct answer it plays its appropriate sound and when clicked on again - plays no sound, which it should, since its now inactive. Same applies to clicking on a wrong answer.

                      However, when I click on another button it sounds once and then silent thereafter.

                      So, my guess is that the code is affecting only the sprite that is clicked on first and not all the sprites at once, which makes sense since I don't have any sendsprite info going out to the other sprites - Would that be right?

                      Any ideas how I can fix this - I haven't a clue about sending info to other sprites.

                      But, I've uniformly put all the buttons on the same channels throughout my movie - 56,57,58,59 - so maybe there's leeway for adding a piece of code to make the other sprites behave or should I say - unbehave!

                      Thanks

                      Andy
                      • 8. Re: Need Help Disabling Button
                        Level 7
                        Ah Yes, you are correct. You need to send a message to all the buttons
                        telling them the question has been answered. So send the message on mouseUp

                        on mouseUp me
                        if Not pQuestionAnswered then
                        sendAllSprites(#QuestionAnswered)
                        -- the rest of your code

                        and add this message handler to the buttons

                        on QuestionAnswered me
                        pQuestionAnswered = TRUE
                        end

                        That should do it (I think), but let me know.







                        andyulrika_is_back wrote
                        > Hi Dave
                        >
                        > Thanks for the replies. I've added your code and this is what happens...
                        >
                        > If I click on the correct answer it plays its appropriate sound and when
                        > clicked on again - plays no sound, which it should, since its now inactive.
                        > Same applies to clicking on a wrong answer.
                        >
                        > However, when I click on another button it sounds once and then silent
                        > thereafter.
                        >
                        > So, my guess is that the code is affecting only the sprite that is clicked on
                        > first and not all the sprites at once, which makes sense since I don't have any
                        > sendsprite info going out to the other sprites - Would that be right?
                        >
                        > Any ideas how I can fix this - I haven't a clue about sending info to other
                        > sprites.
                        >
                        > But, I've uniformly put all the buttons on the same channels throughout my
                        > movie - 56,57,58,59 - so maybe there's leeway for adding a piece of code to
                        > make the other sprites behave or should I say - unbehave!
                        >
                        > Thanks
                        >
                        > Andy
                        >
                        >
                        • 9. Re: Need Help Disabling Button
                          andyulrika_is_back Level 1
                          Brilliant!

                          Thanks Dave, that's fixed it. I only had to update the one script since all the buttons share the same script - which was great.

                          That's saved me a lot of hassle!

                          Many thanks for your input.

                          Regards

                          Andy