a challenge with the quiz using radio buttons
A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: a challenge with the quiz using radio buttons

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    12

    a challenge with the quiz using radio buttons

    Hi everyone

    Please I need assistance with this challenge.

    I designed a simple quiz with radio buttons for the answers. It works fine but I noticed that when i click on the back button to check on a previous question, the checked radio button for the previous question is no longer checked and if i recheck it again, it adds to the score. i figured out that the user might leave out some questions to answer later but with this challenge its not possible. Is there a way or a code that can make the selected answer stick to the radio button even when the user goes back to work on previous questions. your suggestions will be deeply appreciated.


    thanks
    Share on Google+

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Post your .fla. It's hard to help you without a script or a viewable project, because we don't know how you would have possibly made the stuff there. But i can guess you are using frames for the answers, so when you go back to a previews frame, the script RESETS because it is executed again. So you have to init your variables and function in the first frame, and start the quiz on frame 2, and when you press "previous" , it will step back throught all the frames, and you make an if statement in frame 2, to prevent going back to frame 1.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  3. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    12
    Quote Originally Posted by angelhdz View Post
    Post your .fla. It's hard to help you without a script or a viewable project, because we don't know how you would have possibly made the stuff there. But i can guess you are using frames for the answers, so when you go back to a previews frame, the script RESETS because it is executed again. So you have to init your variables and function in the first frame, and start the quiz on frame 2, and when you press "previous" , it will step back throught all the frames, and you make an if statement in frame 2, to prevent going back to frame 1.

    Hello, thanks for your reply. i have been away for a while. i have attached a link to the fla file www.flexsummer.com/quiz.fla as requested.

    thank you in anticipation
    Share on Google+

  4. #4
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Frame 2:
    stop();
    var myscore = 0;
    var array:Array = [];
    var played:Array = [false, false, false];
    startBtn.addEventListener(MouseEvent.CLICK, startQuiz);
    function startQuiz(event:MouseEvent):void{
    nextFrame();

    }
    Frame 3:
    // using the import directive to import the required classes

    import fl.controls.RadioButtonGroup;
    import flash.events.MouseEvent;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

    // starting out with a score of 0

    score.text = myscore+"";
    // creating a new instance of the radioButtonGroup Class
    var mygroup1:RadioButtonGroup = new RadioButtonGroup("group1");
    a1.group = a2.group = a3.group = a4.group = mygroup1;

    if(array[0] != undefined)
    {
    this[array[0]].selected = true;
    }

    b1.addEventListener(MouseEvent.CLICK, quizHandler2)
    function quizHandler2(event:MouseEvent):void
    {
    if(mygroup1.selection != null)
    {
    if(played[0] != true)
    {
    if(mygroup1.selection.label=="Barack Obama")
    {
    myscore+=2;
    played[0] = true;
    array[0] = mygroup1.selection.name;
    }
    }
    }
    nextFrame();
    }

    // firing a 30 second timer
    var myTimer:Timer = new Timer(1000);
    myTimer.addEventListener(TimerEvent.TIMER, countdownHandler);
    function countdownHandler(event:TimerEvent):void{
    countdown.text = 20-myTimer.currentCount+" s remaining";
    if(myTimer.currentCount==20){gotoAndStop(6)}
    }
    myTimer.start();
    Frame 4:
    var mygroup2:RadioButtonGroup=new RadioButtonGroup("group2");
    an1.group=an2.group=an3.group=an4.group=mygroup2;
    score.text=myscore+"";// showing updated score

    if(array[1] != undefined)
    {
    this[array[1]].selected = true;
    }

    b2.addEventListener(MouseEvent.CLICK, quizHandler);
    function quizHandler(event:MouseEvent):void
    {
    if(mygroup2.selection != null)
    {
    if(played[1] != true)
    {
    if(mygroup2.selection.label=="Beijing")
    {
    myscore+=2;
    played[1] = true;
    array[1] = mygroup2.selection.name;
    }
    }
    }
    nextFrame();
    }

    back.addEventListener(MouseEvent.CLICK, backbtn);

    function backbtn (event:MouseEvent):void{
    gotoAndStop(3);
    myscore = myscore;
    }

    b2.addEventListener(MouseEvent.CLICK, backb2)

    function backb2(Event:MouseEvent):void{
    gotoAndStop(5);
    }
    Frame 5:
    var mygroup3:RadioButtonGroup = new RadioButtonGroup("group3");
    ans1.group = ans2.group = ans3.group = ans4.group = mygroup3;
    score.text = myscore+"";

    if(array[2] != undefined)
    {
    this[array[2]].selected = true;
    }

    b3.addEventListener(MouseEvent.CLICK, quizHandler3);
    function quizHandler3(event:MouseEvent):void
    {
    if(mygroup1.selection != null)
    {
    if(played[2] != true)
    {
    if(mygroup3.selection.label=="Joe Biden")
    {
    myscore+=2;
    played[2] = true;
    array[2] = mygroup3.selection.name;
    }
    }
    }
    nextFrame();
    }

    back1.addEventListener(MouseEvent.CLICK, backb3)

    function backb3(Event:MouseEvent):void{
    gotoAndStop(4);
    }
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  5. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    12
    Angelhdz you are a genius.Thank you for the code.different from mine but it works.I discovered it works only on the right answer, how can i correct that to affect the other 3 answers? and also how can a change in the selection of an answer alter the score? just in case the user decides to choose another answer in a previous question.if wrong can it subtract from the present score and if right can it add?


    I deeply appreciate your time and effort.Thank you in anticipation.
    Share on Google+

  6. #6
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Sure. It can be done. I'll work on that in a few minutes, and let you know ^_^
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,104
    Hi,

    You should get into xml a bit more, as you could update your questionnaire without having to access the *.fla file each time.
    At present from looking at your file you need to create a new frame and add all the text and graphics and code each time you wish to add or remove questions, that is not so updateable.

    Your xml could be structured like so
    Code:
    <?xml version='1.0' encoding='utf-8'?>
    
    <questionnaire>
    
      <vars>
    	<timing>20</timing>
    	<scorepoints>2</scorepoints>
      </vars>
    	
      <question>
        <title>Who is the Current President of America?</title>
        <answer>Fidel Castro</answer>
        <answer correct='y'>Barack Obama</answer>
        <answer>Ronald Regan</answer>
        <answer>Nelson Mandela</answer>
      </question>
      
      <question>
        <title>What is the capital of China?</title>
        <answer>Swahili</answer>
        <answer correct='y'>Beijing</answer>
        <answer>Dubai</answer>
        <answer>Jos</answer>
      </question>
      
      <question>
        <title>Who is the vice president of America?</title>
        <answer>Will Smith</answer>
        <answer>Judge Bush</answer>
        <answer correct='y'>Joe Biden</answer>
        <answer>Goodluck Jonathan</answer>
      </question>
           
    </questionnaire>
    to add more questions you would keep the same format for each new one, you can have as many answers as you like, you also add the timer value and the points increment, something to think about
    Attached Files Attached Files
    Last edited by fruitbeard; 04-06-2014 at 12:49 PM.
    Share on Google+

  8. #8
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Ha. Then he says i'm the one who want to increase my posts quantity. I was already helping this person. No reason to you show up like savior here, to boast and brag about your knowledges, implying indirectly that i'm not TOO smart as you, that my scripts are not TOO ADVANCED, and for that reasons you have to appear always like a hero in every post that I'm already helping to give files and scripts and a lot of things to get people's attention. You don't event read previous messages to see if someone else has solved the thread, and to share your thoughts about them, no, you are like an anti-social guy who ignore previous messages, and only want to make files and scripts so people admire you and applauses for you. I give up. Do whatever you want. I won't care about this anymore, but one last thing, I have a lot of knowledge here, i know how to write and load data from XML, in as2 and as3. I know how to make SQLITE databases with the SQLConnection class. I know how to print, i know how to make quizes, so you are not the master here to keep replying to posts that are already getting solved by someone else. Your opinion is not relevant. You don't have to go behind me in every thread, implying my lack of knowledges. Theres a lot of UNSOLVED threads that you can go and boast about your knowledges. But NO, he has to bright and shine in every thread that i'm in. Loser.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  9. #9
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,104
    HI,

    Always ruining peoples threads Angel, you are making yourself disliked by other forum users here too I notice, I am merely pointing out to our man here a different way to his quiz which will make it easier for him to update as and when required. How dare you suggest I'm here to better you or be a saviour. Get over yourself AGAIN.

    Who are you trying to impress here by telling us you know how to do SQL and connection etc etc and other things that have nothing to do with this thread, if you knew about xml then you probably would have suggested it here.

    I do believe from your previous answer that you were going to sort something out for him, I see it not.

    Grow up Angel

    Sorry to fill your thread with this garbage Rayicon.

    If you have problems with me Angel, you start a new thread and not ambush other peoples. I don't answer you pm's asking me not to be an enemy, if you can slag me off in the forum then you can ask me not to be an enemy in the forum too.

    Lets see your reaction next time we help you, if we do that is.

    Have a nice day xx
    Share on Google+

  10. #10
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    The clown here is you. The one how has to grown its you. XML doesn't have anything to do with this thead, either. So? haha.

    But if you want to talk about XML, i can talk about SQL, because it's the same thing haha, DATABASES. Write/Read, store , data. SQLITE, XML, SQL, JSON, same thing. Storing and loading data, in this case, A quiz. So the same thing you did about talking about XML to store the answers and questions of the quiz, I could have do it also, because i have the knowledge and i was the one who replied to the thread first. But NO, you had to appear in already solved threads to leave your opinion always. You could have read the scripts that i posted and bring something useful to it, but not, your opinion is the only thing you care about. Have a nice day as well, i'm having a nice day, just that you make me laugh with your occurrences.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  11. #11
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    Sorry rayicon I will unsuscribe from this thread. If you need further assistance, you can inbox me, or you can keep being assisted by the all-knowing fruitbeard. Have a nice the both. I have a lot of projects today to focus on.
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  12. #12
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Quote Originally Posted by angelhdz View Post
    Ha. Then he says i'm the one who want to increase my posts quantity. I was already helping this person. No reason to you show up like savior here, to boast and brag about your knowledges, implying indirectly that i'm not TOO smart as you, that my scripts are not TOO ADVANCED, and for that reasons you have to appear always like a hero in every post that I'm already helping to give files and scripts and a lot of things to get people's attention. You don't event read previous messages to see if someone else has solved the thread, and to share your thoughts about them, no, you are like an anti-social guy who ignore previous messages, and only want to make files and scripts so people admire you and applauses for you. I give up. Do whatever you want. I won't care about this anymore, but one last thing, I have a lot of knowledge here, i know how to write and load data from XML, in as2 and as3. I know how to make SQLITE databases with the SQLConnection class. I know how to print, i know how to make quizes, so you are not the master here to keep replying to posts that are already getting solved by someone else. Your opinion is not relevant. You don't have to go behind me in every thread, implying my lack of knowledges. Theres a lot of UNSOLVED threads that you can go and boast about your knowledges. But NO, he has to bright and shine in every thread that i'm in. Loser.
    Dude, keep all of your emotions off this forum. I don't know how else to explain it to you because you don't get it. Do three things here, and three things only. Learn, get help, give help. If you can't do those without getting upset, don't post.
    Share on Google+

  13. #13
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Quote Originally Posted by fruitbeard View Post
    HI,

    Always ruining peoples threads Angel, you are making yourself disliked by other forum users here too I notice, I am merely pointing out to our man here a different way to his quiz which will make it easier for him to update as and when required. How dare you suggest I'm here to better you or be a saviour. Get over yourself AGAIN.

    Who are you trying to impress here by telling us you know how to do SQL and connection etc etc and other things that have nothing to do with this thread, if you knew about xml then you probably would have suggested it here.

    I do believe from your previous answer that you were going to sort something out for him, I see it not.

    Grow up Angel

    Sorry to fill your thread with this garbage Rayicon.

    If you have problems with me Angel, you start a new thread and not ambush other peoples. I don't answer you pm's asking me not to be an enemy, if you can slag me off in the forum then you can ask me not to be an enemy in the forum too.

    Lets see your reaction next time we help you, if we do that is.

    Have a nice day xx
    Dude, don't respond. There is no weird emotional fight on a programming forum without two people, there is only one weird emotional outburst.
    Share on Google+

  14. #14
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    You both can talk whatever you want. You both can have the Last Word always. You can post your opinions, ALWAYS. You can critizice scripts, always. But I CAN'T! xD haha.

    It's obvious that you both are arrogant people, that are always bragging about your knowledges. In real life, when someone seeks for help, and someone already appeared to help, and another person shows up, and he or she SEES that there's already someone helping, they don't take the first person appart and say "Hello, I just appeared, let me help you, i will ignore the person that is already helping you. His/Her help is useless, but not mine, so here i am let me upload .zip files with .fla's and stuff to impress and bragging about".

    If you don't want these discussion to happen in this forum, then when there's already someone helping, move on to another unsolved post where your helps is needed. Period.


    You talk about "growing up" but you both are acting like children always defending your points haha
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  15. #15
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,104
    Hi,

    Angel, giving better advice is obviously better, you had a trantrum because I suggested the he use xml so he can update his file far more easily than having to open the fla and add frames and code every time it wanted to be changed, if you can not see the benefit of that then I feel sorry for you.

    I did not however make any remarks to the help you gave or suggest that mine was better or anything else.

    I don't know why you didn't suggest using something that was updateable in the first place.

    Will you please start your own thread about your issues with other forum users answering questions instead of using other peoples and making somebody's thread your chat window.

    You are right Moot, I shall not respond to this.
    Share on Google+

  16. #16
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    953
    "You are right Moot , i shall not respond to this" and you keep responding because you are arrogant people that LOVES to argue and fight xD hahaha! Funny!

    If this person wanted to load data externally they would be notify it. No reason for you to come up with that. But you wanted to impress here.
    And if this persons needed to load data externally from XML, i could have helped him with that, because I was the one already helping him.

    You both are freaking losers, arguing here, instead of helping other people in the as3 forum , that has unsolved threads.

    You keep replying, i will keep replying. Easy as that
    Hi Object, Listen, i wish to return you something, but only if what you are saying is true, else, forget it, ROLL_OVER the floor, i will check for someone else at the stage, while eating a no.visible cookie.
    Share on Google+

  17. #17
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Quote Originally Posted by angelhdz View Post
    You both can talk whatever you want. You both can have the Last Word always. You can post your opinions, ALWAYS. You can critizice scripts, always. But I CAN'T! xD haha.

    It's obvious that you both are arrogant people, that are always bragging about your knowledges. In real life, when someone seeks for help, and someone already appeared to help, and another person shows up, and he or she SEES that there's already someone helping, they don't take the first person appart and say "Hello, I just appeared, let me help you, i will ignore the person that is already helping you. His/Her help is useless, but not mine, so here i am let me upload .zip files with .fla's and stuff to impress and bragging about".

    If you don't want these discussion to happen in this forum, then when there's already someone helping, move on to another unsolved post where your helps is needed. Period.


    You talk about "growing up" but you both are acting like children always defending your points haha
    Dude, keep all of your emotions off this forum. I don't know how else to explain it to you because you don't get it. Do three things here, and three things only. Learn, get help, give help. If you can't do those without getting upset, don't post.
    Share on Google+

  18. #18
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    Quote Originally Posted by angelhdz View Post
    If this person wanted to load data externally they would be notify it. No reason for you to come up with that. But you wanted to impress here.
    And if this persons needed to load data externally from XML, i could have helped him with that, because I was the one already helping him.

    You both are freaking losers, arguing here, instead of helping other people in the as3 forum , that has unsolved threads.

    You keep replying, i will keep replying. Easy as that
    Scroll up. You just told this poster to use frames to control his actionscript and you told him to load a class on a frame. That is not just bad advice it's not acceptable anywhere. You give a lot of bad advice and bad code. Keep typing because you're mad and I'll start correcting your responses.
    Share on Google+

  19. #19
    Junior Member
    Join Date
    Dec 2012
    Posts
    12
    Guys, guys it doesn't have to continue like this. This wasn't the intent for the initial post. Forums are for us to learn and share ideas. Tomorrow i could be the one helping someone. We are all good at something and we definitely do not need destructive criticisms. instead of making someone feel bad, acknowledge his/her ideas then suggest yours. Please we do not need all this. Besides the subject matter has been abandoned.can we return to it please.
    Angelhdz since you started the assist its ok if you want to continue. Its a forum, anyone with a solution/suggestion can advise. Thanks to everyone.
    Share on Google+

  20. #20
    Administrator
    Join Date
    Nov 2011
    Location
    Dallas, TX
    Posts
    63
    angelhdz - you need to take a chill pill to avoid getting banned from here.

    Flaming members here is a huge no no.
    Share on Google+

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width


HTML5 Development Center

Poll by Flashkit.com