5 Replies Latest reply on Jul 23, 2010 1:45 PM by Ned Murphy

    individual feedback for each option

    webster_1c

      Hi all/Ned

       

      Below are links to my fla and swf files. Having been succesfully helped by Ned to resolve one problem, i now find myself facing another. Although in some ways its not a problem because i can get the code to work however as Ned has pointed out i have duplicate code. So what i would like to do is amend the code in the .fla file attached so that each user views indvidual feedback after they have clicked on each checkbox. The question in the swf file is

       

      click on each of  the options below to learn about the different pieces of fruit?

       

      apple

       

      pear

       

      bananas

       

      grapes

       

       

      http://www.4shared.com/video/3BdyKrmu/Quiz1.html

       

      http://www.4shared.com/file/-ZI8zzvr/Quiz1.html

       

      Ned: i thought it would be best to start a new thread as you had actually solved my problem. hope you can help if you have time.

       

      thanks

        • 1. Re: individual feedback for each option
          Ned Murphy Adobe Community Professional & MVP

          I'm still going to show the adjusted code I provided in the other posting.  To have individual feedback for each checkbox you can take the if/else approach you mentioned in the other posting.  I don't know how the ans1 variable is being handled, so I just left it where b is the correct answer...

           

          var ans1 = 0;
          var checkboxListener:Object = new Object();
          checkboxListener.click = function(evt_obj:Object) {

          if (evt_obj.target.selected) {
            checkBox1a.selected = false;
            checkBox1b.selected = false;
            checkBox1c.selected = false;
            checkBox1d.selected = false;
           
            evt_obj.target.selected = true;
           
            if(evt_obj.target == checkBox1a){
               txtOutput.text="You picked an apple";
               ans1 = 0;
            } else  if(evt_obj.target == checkBox1b){
               txtOutput.text="You picked a pear";
               ans1 = 1;
            } else  if(evt_obj.target == checkBox1c){
               txtOutput.text="You picked bananas";
               ans1 = 0;
            } else  if(evt_obj.target == checkBox1d){
               txtOutput.text="You picked grapes";
               ans1 = 0;
            }

          } else {
            ans1 = 0;

            txtOutput.text = "";
          }
          };
          checkBox1a.addEventListener("click", checkboxListener);
          checkBox1b.addEventListener("click", checkboxListener);
          checkBox1c.addEventListener("click", checkboxListener);
          checkBox1d.addEventListener("click", checkboxListener);

          • 2. Re: individual feedback for each option
            webster_1c Level 1

            Morning Ned

             

            Thanks once again, for helping out. it almost works, apart from  when selecting option d: grapes, no feedback is appearing and also at the momment two check boxes can be selected at once boxes c: bananas and d.grapes

             

            Your input is most appreciated

             

            cheers

            • 3. Re: individual feedback for each option
              Ned Murphy Adobe Community Professional & MVP

              Check the instance name used for d (then triple check it).  In your original code you had d spelled differently as compared to the others (B vs b), so I made it consistent with them.

              • 4. Re: individual feedback for each option
                webster_1c Level 1

                Hi Ned

                 

                you're a star, indeed it was the instance name, like you said i had to triple check it.

                 

                Thanks a million.

                 

                 

                • 5. Re: individual feedback for each option
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome