Quantcast
Channel: Adobe Community : All Content - Edge Animate
Viewing all articles
Browse latest Browse all 9897

Recycling for loop iterations

$
0
0

I have a mutliple choice quiz made in Edge. There are 20 questions that are symbols in an array, and a for loop iterates through each question randomly. I would like the questions the user gets wrong to repeat until every question is answered correctly. Here is the code that runs when the user clicks the wrong answer. Is there a way I could just add a line in the for loop to tack the question on to the end of the array?

 

var wrongArr = sym.getComposition().getStage().getVariable("wrongArr");

 

sym.getComposition().getStage().$("correct1").hide();

 

var usedArr = sym.getComposition().getStage().getVariable("usedArr");

var nextQuestionIndex = sym.getComposition().getStage().getVariable("nextQuestionIndex");

 

for (i = 0; i < usedArr.length; i++) {

sym.getComposition().getStage().$(usedArr[i]).hide();

sym.getComposition().getStage().$(wrongArr[i]).hide();

sym.getComposition().getStage().$("wrong1").show();

sym.getComposition().getStage().getSymbol("wrong1").play();

sym.getComposition().getStage().$(usedArr[nextQuestionIndex]).show();

}

 

var prevQuestionIndex = nextQuestionIndex;

nextQuestionIndex++;

 

sym.getComposition().getStage().setVariable("nextQuestionIndex", nextQuestionIndex);


Viewing all articles
Browse latest Browse all 9897

Trending Articles