1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
| public class modelQuestion
{
public function modelQuestion()
{
}
private var listeQuestions:Array;
public function getListe():Array
{
return this.listeQuestions;
}
public function setListe(value:Array):void
{
this.listeQuestions = value;
}
public function chargerQuestions(pEvt:Event):void
{
var fichierXML:XML = new XML(pEvt.target.data);
var questionsListe:XMLList = fichierXML.elements();
var maQuestion:Question;
var nombreAleatoire:int;
var tabGains:Array = ["800", "1500", "3000", "6000", "12000", "24000", "48000", "72000", "100000", "150000", "300000", "1000000"];
var reponsesTab:Array
this.listeQuestions = new Array();
for(var i:int = 0; i < 12 ; i++)
{
nombreAleatoire = Math.floor((Math.random()*(questionsListe.(@type=="800").children().length()))+1);
reponsesTab = [[questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.A.reponse, questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.A..vrai],
[questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.B.reponse, questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.B.vrai],
[questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.C.reponse, questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.C.vrai],
[questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.D.reponse, questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).reponses.D.vrai]];
maQuestion = new Question(questionsListe.(@type==tabGains[i]).children().(@numero==nombreAleatoire).intitule, tabGains[i]+"", reponsesTab, i+1);
listeQuestions[i] = maQuestion;
}
//Alert.show(maQuestion.description());
//Alert.show(questionsListe.(@type=="800").children().length());
//Alert.show(questionsListe.(@type=="800").children().(@numero=="2").intitule);
//Alert.show(nombreAleatoire.toString());
//Alert.show(listeQuestions[8].description());
}
} |
Partager