PDA

View Full Version : Help with flash quiz game please?



stockdill
January 24th, 2004, 09:33 AM
Please help, I am quite new to flash. I am trying to build quizzes to use with pupils at work. I was recommended Gary Rosenzweig's book Action Script for Fun and Games as you can adapt the files to suit your own needs.

If any of you are still reading after admitting I am a bit of a fraud I hope you can help.

I am adapting a multi choice quiz.The game plays a sound to indicate yes or no.. I have changed it myself to make it use dynamic text to appear as correct or wrong after an answer.

A) Is there a way I can make the dymanic test 'correct' or 'wrong' only appear until next question appears?

B) I would like a movie clip to run when they get a question wrong. I have made a thermomator style clip, in each new frame the temperature mounts. When it gets to boiling point it sets of a nuclear bomb. ( I am teaching the cold war).
But I can't get file to work so that when an answer is wrong it goes onto the next frame. To make matters work flash is installed on the school laptop not my own home computer so i can't let you see any of the code just now.

I would really appreciate some help. Thanks
Stockdill:ne:

SeiferTim
January 24th, 2004, 01:28 PM
Download the free trial at: http://www.macromedia.com
To be honest, I have no idea how to lend a hand, it would help if you either attach some code, or the project itself....

claudio
January 24th, 2004, 03:47 PM
Yea, do you have some partial code there?

stockdill
January 24th, 2004, 05:08 PM
Thanks for your replies

This code works
function selectAnswer(n) {
// add to count if correct
if (n == correctAnswer) {
feedback.text = "yes";
numRight++;
} else {
feedback.text = "wrong";


However the following code doesn;t
if (n == correctAnswer) {
bomb.nextFrame();
numRight++;
} else {
feedback.text = "wrong";

Hope this is enough
stockdill:pa:

claudio
January 26th, 2004, 01:23 PM
//place the following objects onstage:
//3 textfields with the instance names: question_txt , answer_txt , result_txt
//1 button with the instance name: my_button
//------------------------------------------
quiz = function (questions, options, q_field, a_field, r_field, button) {
if (questions.length && questions.length == options.length) {
var ref = this;
this.index = -1;
this.q_array = questions;
this.o_array = options;
this.q_field = q_field;
this.a_field = a_field;
this.r_field = r_field;
this.correct_answers = 0;
this.a_field.restrict = "A-Ca-c";
this.a_field.maxChars = 1;
this.nextQuestion();
this.button = button;
this.button.onPress = function() {
if (ref.a_field.text.length) {
ref.checkAnswer();
}
};
this.grade = ["Great!", "Average", "Poor"];
}
};
quiz.prototype.nextQuestion = function() {
if (this.index == this.q_array.length-1) {
this.a_field.text = this.r_field.text="";
this.percentage = Math.round(this.correct_answers/this.q_array.length*100);
this.i = this.percentage>40 ? this.percentage>70 ? 0 : 1 : 2;
this.q_field.text = this.grade[this.i]+"\nYou made "+this.correct_answers+"/"+this.q_array.length+" ("+this.percentage+"%)";
} else {
this.index++;
this.q_field.text = this.q_array[this.index][0]+"\n";
for (var i = 0; i<=this.o_array.length; i++) {
this.q_field.text += this.o_array[this.index][i]+"\n";
}
Selection.setFocus(this.a_field);
}
};
quiz.prototype.checkAnswer = function() {
if (this.a_field.text.toLowerCase() == this.q_array[this.index][1]) {
this.r_field.text = "Correct!";
this.correct_answers++;
} else {
this.r_field.text = "Wrong!";
}
this.myInterval = setInterval(this, "reset", 2000);
};
quiz.prototype.reset = function() {
this.a_field.text = this.r_field.text="";
clearInterval(this.myInterval);
this.nextQuestion();
};
//------------------------------------------
//array with the questions and the correct option
questions_array = [["1. The real St. Nicholas lived:", "c"], ["2. Who is making the Web standards?", "a"], ["3. What does HTML stand for?", "c"]];
//array with the options
options_array = [["a. At the North Pole", "b. In Holland", "c. In Turkey"], ["a. The World Wide Web Consortium", "b. Netscape", "c. Microsoft"], ["a. Hyperlinks and Text Markup Language", "b. Home Tool Markup Language", "c. Hyper Text Markup Language"]];
myQuiz = new quiz(questions_array, options_array, question_txt, answer_txt, result_txt, my_button);

zeka
January 29th, 2004, 04:11 AM
wow

Marz
January 29th, 2004, 04:15 AM
That's great and everything... But now you've limited him to text fields... And for a simple GUI interface with a quiz game that's limited to a,b, or c... He'll probably want to use graphics that you can click for answering..

At least, that would be more logical..

Albeit.. Not a bad start :)

WarrOrange
February 4th, 2004, 06:53 PM
.. woah claudio....... !!!!!!!!!! thats a lot of FREEKIN code