Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-20-2005, 09:08 PM   #1
milohound
Registered User
 
Join Date: Jan 2002
Posts: 29
Default Multiple answers to 1 question in Flash Quiz?

I have followed Colin Moock's example of the multiple choice quiz (array method). But instead of having only one answer per question, I need to allow the user to have the choice of 2 or even three possible answers to one question. How would i do this?

var correctAnswers = [3,1];
numQuestions = correctAnswers.length;

this is obviously only working properly if there are three questions. I want one question but three anwers..

here's my buttons code:
ActionScript Code:
tick1.onRelease = function(choice) {     if (tick1.tickBox._currentFrame == 2) {         answer(1);     } else if (tick1.tickBox._currentFrame == 1) {         userAnswer.pop();     } }

Last edited by CyanBlue; 02-21-2005 at 02:14 AM. Reason: AS tag is applied...
milohound is offline   Reply With Quote
Old 02-20-2005, 09:37 PM   #2
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

Hmmm not realy understand you

but here somthing to play around

ActionScript Code:
//The foloving components HAVE to by in the library //RadioButton , Button , TextArea import mx.controls.RadioButton; import mx.controls.Button; import mx.controls.TextArea; Q = ["1+2=3", "4*3=?", "Green is a"]; A = [{a1:"Yes", a2:"No"}, {a1:"10", a2:"12", a3:"20"}, {a1:"Color", a2:"Tree", a3:"a Drink", a4:"a Car"}]; C = [1, 2, 1]; UserA = []; function Qestion(Nr) {     clearInterval(IntVal);     if (!Q[Nr]) {         CheckAll(Nr);     } else {         x = 0;         _root.createEmptyMovieClip("Q_Bord"+Nr, 1);         _root["Q_Bord"+Nr]._x = 200;         _root["Q_Bord"+Nr]._y = 300;         _root["Q_Bord"+Nr].createTextField("my_txt", 1, 0, 0, 300, 100);         _root["Q_Bord"+Nr].my_txt.text = "Q: "+Q[Nr];         for (a in A[Nr]) {             _root["Q_Bord"+Nr].createClassObject(RadioButton, x, x+2, {label:A[Nr][a]});             _root["Q_Bord"+Nr][x].groupName = "Grup";             _root["Q_Bord"+Nr][x]._y = 20*x+50;             x++;         }         _root["Q_Bord"+Nr].createClassObject(Button, "check", x+2, {label:"check", _y:80+20*x});         _root["Q_Bord"+Nr].check.onPress = function() {             CheckIt(Nr);         };     } } function CheckIt(Nr) {     if (_root["Q_Bord"+Nr][C[Nr]-1].selected) {         _root["Q_Bord"+Nr].my_txt.text = "Yupae  Corect";         UserA[Nr] = true;     } else {         _root["Q_Bord"+Nr].my_txt.text = "Hmmm Mayby Next time";         UserA[Nr] = false;     }     IntVal = setInterval(Qestion, 1000, Nr+1); } function CheckAll(Nr) {     createClassObject(TextArea, "All", 1, {_x:300, _y:100, _width:300, _height:400});     for (a=0; a<Nr; a++) {         (!q) ? q=1 : q++;         if (w == undefined) {             w = 0;         }         _root.All.text += a+" Q: "+Q[a]+" Your Anser is :"+UserA[a]+"\r";         if (UserA[a]) {             w++;         }     }     _root.All.text += "\r"+"you Have "+w+" out of "+q; } Qestion(0);
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 02-20-2005, 09:55 PM   #3
milohound
Registered User
 
Join Date: Jan 2002
Posts: 29
Default

no this isnt what i mean. If you want to understand me better read through colin Moock's flash quiz 3 example and then ask yourself, " why cant a question have more than one possible answer?" --- this is what im trying to do. I am not using any components for this just as Colins example.
milohound is offline   Reply With Quote
Old 02-20-2005, 10:07 PM   #4
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

i am fare to lazzy to go truh this !!!!

if you upload a working file (FLA) i take a look an see what i can do
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 02-20-2005, 10:10 PM   #5
milohound
Registered User
 
Join Date: Jan 2002
Posts: 29
Default

Thanx, i have attached the fla to feast your eyes over.
milohound is offline   Reply With Quote
Old 02-20-2005, 10:30 PM   #6
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

Hmmm not see any attachment !

think on it you can upload ZIP but no FLA
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 02-20-2005, 10:41 PM   #7
milohound
Registered User
 
Join Date: Jan 2002
Posts: 29
Default

try this...
Attached Files
File Type: zip quizTest.zip (3.4 KB, 1530 views)
milohound is offline   Reply With Quote
Old 02-20-2005, 11:08 PM   #8
Xeef
Off-Line
 
Xeef's Avatar
 
Join Date: Aug 2004
Location: Ibiza/Spain language :Hungarian/German/ abit English
Posts: 6,539
Default

Huhhhhhh

there are a lot of logic errors

1.
you store the Number of the ancer was given eg:
appel-->1
wheat-->2
and so on
then compare it ageins the corect ancers eg [1,3]
so fare so good but if i select banana first and then appel it will by 3,1 and NOT 1,3

this coud by solved that you SORT the array before checking

ActionScript Code:
A = [3, 1]; trace(A); A.sort(); trace(A); //this works here but //Numeric fields are sorted as if they were strings, //so 100 precedes 99, because “1” is a lower string //value than “9”. // //there fore function SORT(a, b) {     if (a<b) {         return -1;     }     if (a>b) {         return 1;     }     if (a == b) {         return 0;     } } B=[1,43543,12,100,3] trace(B) B.sort() trace(B) B.sort(SORT) trace(B)

other BIG problem is (not sure you have or not realize it)
select Appel then select banana then deselect Appel --watch the output
it's INCORECT (1 shoud by 3)

try around if you have no success bump it up tommorow i am going to bed
__________________

test your self -->http://www.actionscript.org/forums/s...86&postcount=8
Xeef is offline   Reply With Quote
Old 02-20-2005, 11:11 PM   #9
milohound
Registered User
 
Join Date: Jan 2002
Posts: 29
Default

thanx for you hellp.
milohound is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:02 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.