Solved

Posted on 2012-08-24
309 Views
Current project includes a ten page quiz.
Each question has a choice of three answers, each is related to a colour ( red,amber,green)
When a question choice is made a box is populated by a colour fill and goes to the next
question frame. As the questions are answered the boxes progress across the stage until the final box.
I need to find a way to add up which colour has filled the most boxes and the move to the appropriate frame with a statement that relates to total.
0
Question by:Fairfax103

LVL 4

Accepted Solution

The 'box fill' is a visual cue for the user, I'm guessing - telling them how they did for that question. But 'underneath' the visual skin of the program you just need some sort of counter that keeps track of the responses.

So I can think of 2 ways to do this.

1) You initialise a variable to record a score - let's call the variable 'totalScore'. You assign a value to each of the colours - for example, red = 0, amber = 1, green = 2. So when a user answers with a 'green' answer your code would be

totalScore = totalScore + 2;

totalScore = totalScore + 1;

You keep track of the score, and end up with a total score after all the questions have been asked. You can then take a decision on what feedback to give based on what score they got versus the maximum score possible.

You say there are 10 pages, so if we used this marking scheme, the maximum score would be 20 - all green. So you might 'split' the feedback at a score of 5, 10 and 15. You then just need a bunch of 'if' statements something like

if (totalScore <= 5) {
...take some actions here
}

if ((totalScore > 5) && (totalScore < 10)) {
...take some actions here
}

if ((totalScore >= 10) && (totalScore < 15)) {
...take some actions here
}

if (totalScore >= 15) {
...take some actions here
}

or

2) Setup three variables to record the 'colour' of each answer - we'll call them 'redAnswer' 'amberAnswer' and 'greenAnswer'. Before the quiz starts we set them all to 0

Then each time you get a 'red' answer you use the code

and if you get an amber answer you use

and I'm sure you can work out what code you need if you get a green answer.

At the end of the quiz, you just need to compare the three variables to see which is largest. Bear in mind that using this method, it's quite likely that two of the variables will be the same value, so you'll have to think what decision needs to happen in that case. Note that all three variables can never be the same since 10 (the number of questions) cannot be divided equally when using whole numbers only.
0

Author Closing Comment

Thanks a lot
0

## Featured Post

### Suggested Solutions

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…