View Full Version : quiz...
pHrOsT
07-14-2003, 11:31 AM
Hey I have a True/False quiz with 10 questions. The score is kept by variable "score" which is a dynamic text box. If the player presses the correct button then the code goes something like this:
on(release) {
play();
score = score + 1
}
and it adds 1 to the players score, if they answer incorrectly it skips ahead to the next question...now all of that is working fine, but I'd like it so that if the player accumilates 5 or more points, it will skip ahead to the ending scene. How could i achieve this? Maybe something like this? It doesn't seem to be reading it though...
if (score==1,2,3,4) {
play();
} else if(score==5,6,7,8,9,10,11) {
gotoAndPlay("end", 0);
}
pHrOsT
07-14-2003, 11:57 AM
thanx. i had alrdy tried
if (score==score<5) {
play();
}
and that had not worked so i didnt think to take out one of the scores...ahh...the life of a newbie... :)
pHrOsT
07-14-2003, 12:07 PM
ok now for the next (and last problem)...how could I create a random effect so that when you get a question right or wrong it would randomly go to another question out of the 10 with no repeats? I was thinking you could label the first frame of each of the 10 questions a specific name and then set up an array with all 10 names. The problem is, i have no expierience with arrays...any ideas on how this can be done (or ne tips that could push me in the right direction?)?
red penguin
07-14-2003, 12:39 PM
how could I create a random effect so that when you get a question right or wrong it would randomly go to another question out of the 10 with no repeats?
Assuming you have the questions in an array, randomize this array before the quiz:
Array.prototype.random=function(){
this.sort(function(){return Boolean(random(2))});
}
arr_q=["q_1","q_2","q_3","q_4","q_5","q_6"];
arr_q.random();
trace(arr_q);
pHrOsT
07-14-2003, 02:14 PM
thanx, im sure that will work...but how do u lable specific frames of a scene so that u can use them in an array?
red penguin
07-14-2003, 04:08 PM
how do u lable specific frames of a scene Uhmmmm...like in the properties panel, just label the frame.
On a side note, I would go to moock's site and browse what he has for quizzes. It'll help you a great deal....
pHrOsT
07-14-2003, 05:03 PM
right, that helped a bunch (btw i knew how to label frames, i just didnt know if they worked the same as instance names that could be called upon)...now that the array is set up...there's one final piece to the puzzle...lets say after the player answers a question it will play a fade out animation for a few frames and on the last frame of the fade out animation it would need some script such as this:
[AS]gotoAndPlay(arr_q.random)AS]
so that when it reaches the frame it will move on randomly to the next frame in the array (while not repeating, although that may be imbeded in the array when you set it up?). Do I have the right idea/ is that code above correct?
red penguin
07-14-2003, 07:24 PM
1. If you want to have the questions in a random order, you merely have to call that prototype ONCE at the onset of the test.
Array.prototype.random=function(){
this.sort(function(){return Boolean(random(2))});
}
arr_q=["This is question one.","This is question two.","This is question three.","This is question four.","This is question five.","This is question six."];
arr_q.random();
Then when you want to display the questions, you just have to have a variable to increase. Let's call it current_question.
current_question=0;
this.str_question=arr_q[current_question++];
On 'this' timeline, we have a textField named str_question. It is displaying the first index in that array. Then when you want another question, just have to call it like that...
Have you gotten any of Moock's examples?
pHrOsT
07-15-2003, 11:29 AM
I've tried that text field way but it doenst seem to be working...
couldn't I just label the frames like "q_1" , "q_2" ect... and then put in
gotoAndPlay(arr_q[0]);
to go to the 1st question in the array and then on the last frame of that question right at the end of the fade out put
gotoAndPlay(arr_q[1]);
to get to question 2 of the array...I've tried that however and it just jumps back to the initial scene and frame...ne ideas on why?
btw i've also tried putting mc's in each of the beggining frames of the questions and labeling them "q_1" , "q_2" , etc. but that doesn't work either. :(
pHrOsT
07-15-2003, 03:04 PM
k i got it figured out...when using named frames to be reffered to in an array, you can only use numbers (in naming them)...and they might have to be the same number as the frame number itself, i havent checked it yet.
thanx for all the help red penguin, c ya around! :cool:
red penguin
07-15-2003, 07:21 PM
Got Moock?
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.