Hi all, I’m making a quiz and wanted to highlight the correct answer with green and red if it’s wrong. But when i right the else statement it comes up else in unexpected.
btnCheck.addEventListener(MouseEvent.CLICK, chkAnswer);
function chkAnswer(mevt:MouseEvent):void {
//if (cdlCorrect[index] == cdlUserAnswers[index]) {
cdlDone[index] = 1;
var rectSize:uint = 300;
var correctRect:Shape = new Shape();
var wrongRect:Shape = new Shape();
correctRect.graphics.beginFill(0x00FF00, 0.5);
wrongRect.graphics.beginFill(0xFF0000, 0.5);
//if(cdlUserAnswers[index] == 0) {
//}
if(cdlCorrect[index] == "0") {
correctRect.graphics.drawRect(45, 50, rectSize, 25);
}
if(cdlCorrect[index] == "1") {
correctRect.graphics.drawRect(45, 85, rectSize, 25);
}
if(cdlCorrect[index] == "2") {
correctRect.graphics.drawRect(45, 120, rectSize, 25);
}
if(cdlCorrect[index] == "3") {
correctRect.graphics.drawRect(45, 155, rectSize, 25);
}
if (cdlCorrect[index] == cdlUserAnswers[index]) {
}
qHolder.addChild(correctRect);
//}
else {
//correctRect.visible = false;
//}
}
if(cdlUserAnswers[index] == "0") {
wrongRect.graphics.drawRect(45, 50, rectSize, 25);
}
if(cdlUserAnswers[index] == "1") {
wrongRect.graphics.drawRect(45, 85, rectSize, 25);
}
if(cdlUserAnswers[index] == "2") {
wrongRect.graphics.drawRect(45, 120, rectSize, 25);
}
if(cdlUserAnswers[index] == "3") {
wrongRect.graphics.drawRect(45, 155, rectSize, 25);
}
if (cdlCorrect[index] != cdlUserAnswers[index]) {
}
qHolder.addChild(wrongRect);