Reputation: 7285
The title kinda says it all..
I am creating a quiz and I set one quiz block with questions into a movieclip. When the person answers the correct answer I want it to add to a counter and pass that value onto the next movieclip. So movieclip one is added to the stage it does something then adds a counter. Then moves to the next frame and movieclip2 is added to the stage. It does something and add to the same counter variable from movieclip1. And so on and so on until no more movieclips.
Upvotes: 0
Views: 948
Reputation: 39466
Try a quick and easy class like this:
package
{
public class Scoreboard
{
// Constants
public static const TOTAL_QUESTIONS:int = 3;
// Score value
public static var correct:int = 0;
/**
* Returns success rate as a percentage in decimal form
*/
public static function get successRate():Number
{
return correct / TOTAL_QUESTIONS;
}
}
}
Where you can change the TOTAL_QUESTIONS
as you like, and do the following:
Scoreboard.correct += 1; // Adds a correct answer
Scoreboard.correct = 0; // Reset the quiz
trace(Scoreboard.successRate); // Output the success rate based on correct answers at the end.
Upvotes: 2