• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

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.
}

}

TOPICS
ActionScript

Views

847

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

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);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

I did try the following:

back_btn.addEventListener(MouseEvent.CLICK, goClickMe);

function goClickMe(event:MouseEvent):void {

MovieClip(parent).gotoAndStop(1);      

removeChild(root.feedback);

}

and a few other variations within the "back" button code, but was not able to make the feedback movieclip disappear.

As for having the user cheat, I do mean that when the user is doing the quiz, and they answer incorrectly, a movie clip pops over covering the whole screen and they are made to read information in regards to the question they are answering before going to answer the question again. As of right now, they can answer the question wrong and then select another answer and click submit and answer it again until they get it correct without having to read the pop up movieclip. Sorry if it was hard to understand. Regards

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 17, 2014 Dec 17, 2014

Copy link to clipboard

Copied

LATEST

You should try to code consistently.  If...

MovieClip(parent).gotoAndStop(1);    

works to tell the main timeline to go to frame 1, then you should continue to target it in that manner.

What you could do is have a function in the main timeline that removes the feedback object.  The way you wrote it (removeChild(root.feedback);), if the code is inside the movieclip, then it is trying to target inside the moveclip to remove something on the main timeline, but the inside of the movieclip has no such child to remove.

If you can work out ways of keeping all your code in the main timeline instead of scattering it into various movieclips you will find it is alot easier to manage targeting things.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines