-
Quiz with score system
I'm trying to make a simple quiz in cs6 with actionscript 2.0. Basically there are 8 questions and each question has 3 possible answers. For each answer I want to assign a different score. Depending on the total score, a different text is displayed at the end of the quiz. What is the best/easiest way to code this? Graphically-wise, the quiz is as good as finished (as it's pretty basic) and I already have programmed the actions of clicking the 3 possible answer buttons and the start button etc. I only don't know how to make this score system. I found someone who already asked my question here but he didn't really get much of an answer nor did I understand his code. Can somebody please help me out? I'd really appreciate it. Thanks in advance.
I added this to one of the buttons in the beginning:
Code:
on (release) {
_global.score=0;
_global.score=_global.score+x;
}
At the last couple questions I added this script (it's supposed to view a template with the result of the quiz based on the total score):
Code:
on (release) {
if (score<=x) {
gotoandstop(y);
} else if (score=x or x or x or x) {
gotoandstop(y);
} else if (score>=x) {
gotoandstop(y);
} else {
gotoandplay(y);
}
I replaced the actual numbers with x and y because you obviously can't know how I organized the templates. But somehow in the last script the total score calculation doesn't give the correct result...
Can someone PLEASE help me, it's urgent.
-
.
Hi,
Firstly you might want to put this on the timeline by itself, im not sure.
_global.score = 0;
then on the two of your buttons have these codes
PHP Code:
on (release) {
if (score <= x || score >= x)
{
gotoAndStop(y);
}
else if (score == x || score == x || score == x || score == x)
{
gotoAndStop(y);
}
else
{
gotoAndPlay(y);
}
}
PHP Code:
on (release) {
_global.score = _global.score + x;
}
gotoandplay should be gotoAndPlay, gotoandstop should gotoAndStop, capitals, most important for it to work.
good luck
code explained
PHP Code:
on (release) {
// if score less than, equal to, or higher than **
if (score <= x || score >= x)
{
gotoAndStop(y);
}
// if score is equal to ** or score is equal to ** or ** or **
else if (score == x || score == x || score == x || score == x)
{
gotoAndStop(y);
}
// if score not similar to any of the above
else
{
gotoAndPlay(y);
}
}
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|