2 Replies Latest reply on May 18, 2009 12:36 PM by cterry06

    Can Flash remember buttons clicked for a game?

    cterry06

      I am making a game for the university I attend.  I am having students choose between college and high school by two buttons to see if they choose the correct answer. Then I want it to display the number correct on a result page I will have them print out for the instructor of their freshman seminar class.

       

      Can flash remember if a specific button was clicked?  I have each button with a unique name and could it tell which one was clicked to help me figure out results?

       

      Otherwise, I was wondering if there was a way I could have flash keep track of "points" so I can display the number correct.  Would it be possible if I gave each button a numeric value and somehow added up the numbers from each button to put over a total score of 12 (that's how many questions there are)?  Could it be done in a dynamic text field?

       

      I have attached my .swf file so anyone that can help can see what I'm trying to explain.

       

      Thanks!

        • 1. Re: Can Flash remember buttons clicked for a game?
          Ned Murphy Adobe Community Professional & MVP

          Pretty much any of what you described is possible.  What I would probably do is create an array of objects, one object for each answer the student supplies.  The object could identify the button that was clicked and whether or not the selection was correct, and any other data you'd like the object to carry.

           

          An object is represented in code by curly braces { }  and carries properties/variables within it, pretty much any you choose.

           

          answers[i] = {buttonClicked: button1, correctAnswer: true};

           

          In that example, I am assigning an object to an array (answers) that contains two variables: buttonClicked & correctAnswer.  The button that was clicked has the instance name button1, and the user made the correct choice (true)

           

          Later on, if I want to go use that data, I would use:  answers[i].buttonClicked & answers[i].correctAnswer  to get the values.

          • 2. Re: Can Flash remember buttons clicked for a game?
            cterry06 Level 1

            Thanks a lot...with the help of a fellow worker and his advice we got it to work.

             

            we declared a variable, and added to it every time it was right.  I attached it so you can see

             

            Thanks again!