Bonjour,
Je suis en train de realiser un QCM dont le chargement est interactif. En effet, la liste des questions est contenu dans un fichier XML. J ai donc redige le code AS suivant :
numero=0
stop();
question = function(i) {
x = myXML.firstChild;
question = x.childNodes[i].attributes.enonce;
reponse1.setLabel(x.childNodes[i].childNodes[0].attributes.reponse)
reponse2.setLabel(x.childNodes[i].childNodes[1].attributes.reponse)
reponse3.setLabel(x.childNodes[i].childNodes[2].attributes.reponse)
reponse4.setLabel(x.childNodes[i].childNodes[3].attributes.reponse)
point1 = x.childNodes[i].childNodes[0].attributes.point;
point2 = x.childNodes[i].childNodes[1].attributes.point;
point3 = x.childNodes[i].childNodes[2].attributes.point;
point4 = x.childNodes[i].childNodes[3].attributes.point;
trace(point1)
}
myXML = new XML();
myXML.ignoreWhite = true;
myXML.load("question.xml");
myXML.onLoad = function(flag) {
question(0)
};
action = function () {
if (reponse1.getValue() == true) { total=total+point1}
if (reponse2.getValue() == true) { total=total+point2}
if (reponse3.getValue() == true) { total=total+point3}
if (reponse4.getValue() == true) { total=total+point4}
trace(total);
numero=numero+1
trace(numero)
question(numero)
}
bouton.setClickHandler("action" ,this)
Explication:
- numero est le numero courant de la question (0 etant la premiere question)
- la fonction question(i) permet d afficher dans un claque specifique aux composants les differents labels . Question etant un texte dynamique et reponse1,2,3,4 etant des checksbox.
Lors du chargement du XML (XML.onLoad) , j affiche la question 1 par question(0) . Lorsqu on appuye sur le bouton "Bouton" on enregistre le score selon la checkbox selectionne et on incremente le numero de la question puis on affiche la question suivante question(numero). Le probleme est que la question affiche reste tjs la premiere.
Il n a pas l air de rafraichir le calque . A koi c du ?