create a quiz with actionscript 3

17 Views Asked by At

I am trying to create a quiz with actionscript 3 but this error is also showing.

TypeError: Error #1010: A term is undefined and has no properties. at Sansnom_3_fla::MainTimeline/checkAnswer()[Sansnom_3_fla.MainTimeline::frame1:49]

     var quiz:Array = [
    {
        question: "Quels sont les verbes employés avec l'auxiliaire 'être'?",
        options: ["venir", "aller", "partir", "ranger"],
        answer: [0, 1, 2] // Indices des réponses correctes dans le tableau des options
    },
    // Ajouter d'autres questions dans le même format
];

// Mélanger le tableau de questions
quiz.sort(function(a:Object, b:Object):Number {
    return Math.random() - 0.5;
});

// Initialiser les variables pour suivre la question actuelle et le score
var currentQuestion:int = 0;
var score:int = 0;

// Afficher la question actuelle et les options
questionText.text = quiz[currentQuestion].question;
option1.text = quiz[currentQuestion].options[0];
option2.text = quiz[currentQuestion].options[1];
option3.text = quiz[currentQuestion].options[2];
option4.text = quiz[currentQuestion].options[3];

 var correctAnswers:Array = quiz[currentQuestion].answer;
    var isCorrect:Boolean = true;

    if (selectedAnswers.length != correctAnswers.length) {
        isCorrect = false;
    } else {
        for each (var answer:int in selectedAnswers) {
            if (correctAnswers.indexOf(answer) == -1) {
                isCorrect = false;
                break;
            }
        }
    }


0

There are 0 best solutions below