Tracking Correct Answers in Quiz

I want to know before I attempt this, if it can be done. I have a multiple choice quiz, the user is allowed one choice because the answers are radio buttons. I want to keep track of how many right answers the user gets out of a possible ten questions.
Here is how the quiz is set up…the user clicks on an mc object, which then loads an swf containing the question into a container mc. Once an answer has been selected the swf containing the question will be unloaded. Now, I know to start the process of being able to track the right answers for user feedback, I will have to define some varibles in the first frame of my main movie. This is what confuses me…how will I pull data from the question.swf’s to use in my main movie?
Maybe this is something that is done all the time I just have never done it before. I am going to start working on it and see how far I get, am look forward to getting comments from all you AS pros out there.

I know it can be done because the programmer I work with has done it with I guess you would call it an array, if thats the correct pronuciation. I think as long as that script is on the root and in the first frame you are okay.

Does this example code help at all? It basically loads the questions and answers in the frame with radio buttons, checks the answers and displays them with the question page once answered and so on.

var printCount = 0;
// answer array will hold the scores for each choice within each answer.
var answers = [[1, 2, 4, 5], [1, 3, 5], [1, 4, 6, 8, 10], [5, 4, 2, 1], [1, 3, 5], [8, 6, 4, 2, 0], [0, 3, 5, 8], [0, 3, 5, 8]];
// set the change handler for the whole group
// choices array will hold the choices for each question.
var choices = [[“Increasing current income”, “Education expenses”, “Retirement”, “Long-Term wealth accumulation”], [“Yes, I need the portfolio income”, “No, but I will need to begin receiving the income within five years”, “No, income may be invested for longer than five years”], [“5 years or less”, “6-10 years”, “11-15 years”, “16-20 years”, “Over 21 years”], [“Increase much faster than inflation”, “Increase steadily at the rate of inflation”, “Remain about the same”, “Slowly decrease”], [“No, I have less than two months of income”, “Yes, for two to six months of income”, “Yes, for greater than six months of income”], [“A lot more risk with most of my money”, “A lot more risk with some of my money”, “A little more risk with most of my money”, “A little more risk with some of my money”, “No additional risk”], [“Portfolio A”, “Portfolio B”, “Portfolio C”, “Portfolio D”], [“Portfolio A - average annual rate of return of 4%; annual returns with minimal fluctuations”, “Portfolio B - average annual rate of return of 6%; annual returns two-thirds of the time fluctuate between -3% and 15%”, “Portfolio C - average annual rate of return of 10%; annual returns two-thirds of the time fluctuate between -9% and 31%”, “Portfolio D - average annual rate of return of 12%; annual returns two-thirds of the time fluctuate between -21% and 47%”]];
// userAnswer array will hold the answers (a,b,c,d…) selected by the user for each question.
var userAnswers = new Array(-1, -1, -1, -1, -1, -1, -1, -1);
// score array will hold the points based on what the user selected for each answer.
var score = new Array(-1, -1, -1, -1, -1, -1, -1, -1);
var totalScore = 0;
function preLoadAnswers(radioG, qNum) {
qNum = qNum-1;
uAnswer = _root.userAnswers[qNum];
if (uAnswer != -1) {
numOfChoices = _root.choices[qNum].length;
for (var i = 1; i<=numOfChoices; i++) {
if (uAnswer == i) {
function setAnswer(radioG, qNum) {
// Adjust the real number to the array index so subract 1
qNum = qNum-1;
userAnswer = radioG.getValue();
numOfChoices = _root.choices[qNum].length;
for (var i = 0; i<numOfChoices; i++) {
if (userAnswer == _root.choices[qNum]) {
_root.score[qNum] = _root.answers[qNum]
_root.userAnswers[qNum] = (i+1);
userResponseBox = eval("_root.userResponse"+(qNum+1)+"_txt");
userResponseBox.text = userAnswer;
function resetQuiz() {
for (var i = 1; i<=score.length; i++) {
resetField = eval(“userResponse”+i+"_txt");
resetField.text = “”;
score[(i-1)] = -1;
userAnswers[(i-1)] = -1;
totalScore = 0;
function submitQuiz() {
totalScore = 0;
for (var i = 0; i<score.length; i++) {
if (score* != -1) {
// trace ("Answer “+(i+1)+” : "+score*);
totalScore = totalScore+score*;
if (totalScore<=18) {
} else if ((totalScore>=19) && (totalScore<=24)) {
} else if ((totalScore>=25) && (totalScore<=30)) {
} else if ((totalScore>=31) && (totalScore<=37)) {
} else if ((totalScore>=38) && (totalScore<=44)) {
} else if (totalScore>=45) {
// trace ("Total Score: “+totalScore+”


Whoa. I think I got a lot more than I was expecting :smiley:
I am hoping to be able to work the scorekeeping into what I already have, and this seems to be a whole new approach to writing the entire quiz. As of right now, I have a change handler function that is called when each button is selected that gives further instructions such as giving a message to the user: You’re right or Sorry you are wrong, and then unloads the movie. It looks as though I am going to need to work the score tracking into that function as well, at least that is what I am getting from what I saw in the code you posted.
Thanks for the example and hopefully I can understand it enough to apply it to what I need.