Skip to main content
Known Participant
December 17, 2014
Question

Quiz - how to get back to main timeline and reset question

  • December 17, 2014
  • 2 replies
  • 963 views

Hey everyone, I have a flash files using as3 and on frame one of the timeline is a movie clip is a quiz and the user picks 1 or 3 possible answers. If the user selects the wrong answer, it opens another movie clip on top of the existing with a review. From there, there is a back button which I have going back to the first frame and it re-asks the question again. The problem I am having is when the user goes back, the answer they selected is already selected. I would like the question to be reset.
Here is my back code which takes me back to the main timeline

back_btn.addEventListener(MouseEvent.CLICK, goClickMe);

function goClickMe(event:MouseEvent):void {
MovieClip(parent).gotoAndStop(1);
}

and here is the code I have on the first frame of the quiz:


var radioGroup1:RadioButtonGroup = new RadioButtonGroup("Question 1");
var feedback:MovieClip;
rb1.label = "A";
rb2.label = "B";
rb3.label = "C";

rb1.group = radioGroup1;
rb2.group = radioGroup1;
rb3.group = radioGroup1;

submit_btn.addEventListener(MouseEvent.CLICK, submitClick);

function submitClick (event:MouseEvent):void {

  if (radioGroup1.selection == null) {
return;
}
if (radioGroup1.selection.label == "A") {

feedback = new Feedback1();
feedback.x = 0;
feedback.y = 201;
addChild(feedback);
}
    if (radioGroup1.selection.label == "B") {
feedback = new Feedback2();
feedback.x = 0;
feedback.y = 201;
addChild(feedback);

}
if (radioGroup1.selection.label == "C") {
feedback = new Feedback5();
feedback.x = 0;
feedback.y = 201;
addChild(feedback);
m_VariableHandle["slideVisited" + m_VariableHandle.cpInfoCurrentSlide] = 1; //Put this line of code where right answer is.
}

}

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
December 17, 2014

You must have changed the posting while I was answering the first version of it.

One way to deal with resetting radio buttons is to have an extra one out of sight that you assign as the selected one.  So for the code you show, if you add a fourth radio button off-stage and set it to be selected thru code in frame 1 then when you return to frame 1 it should re-select the off-stage one.

kuraziAuthor
Known Participant
December 17, 2014

So sorry - I was posting my issue after trying to figure it out for some time and then all of the sudden i figured it out but ran into another problem!!

Seems like that is usually the case for me

I was able to get all of the issues resolved except for removing a movie clip from the stage when the user is taken back to the first frame - the radio button issue has been resolved, thank you. Here is what happens - the user selects one of the 3 answers and the "incorrect feedback" movie clip pops up on screen.

They click the "review" button on the feedback and the "review" page fades in and they read. When they are done, they click "back" which takes them back to the first frame, and they redo the quiz - but the "incorrect feedback" text is still on the screen.

I am not quite sure on how to remove that movieclip from the stage when the user goes back to redo the quiz.

I am also wondering if it is possible to make it so the user can only select one answer each time they try to answer the quiz so they do not cheat and find the correct answer and not have to read the review.

Any pointers would be great -  thanks again.

Ned Murphy
Legend
December 17, 2014

How you remove the incorrect feedback movieclip depends on how you make it appear to begin with.  Chances are whatever you do will get done with the code that executes with the Back button.

I do not know how to answer your last wondering.  Not becase I can't figure out a solution, but because I do not understand how the user can cheat and find the correct answer and no read the review.  What you describe almost seems to say that you do not want them to be able to go Back and answer a question again... if that is the case then get rid of the Back button.

Ned Murphy
Legend
December 17, 2014

Your second attempt is the more correct version. The first is wrong.  If you only have one scene, try it without using the scene parameter.  You might want to put a trace in the function just to make sure the function is being called when you click the button.

An alternative approach could be to put the code in the main timeline (if the Back button is targetable from it)...

movieclipname.back_btn.addEventListener(MouseEvent.CLICK, goClickMe);

function goClickMe(event:MouseEvent):void {

       gotoAndStop(1);

}