![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|||||
|
Регистрация: Apr 2013
Сообщений: 77
|
Я так и не нашел, что у Вас questionTxt. Но ошибка вот тут, скорее всего.
Т.к в Вашем коде, который Вы скинули изначально у Вас всего 1 значение excercise. |
|
|||||
|
[+1 05.06.13]
Регистрация: Mar 2013
Сообщений: 42
|
questionTxt, обычный динамический текст.
question_id: Данные XML: Добавлено через 21 час 44 минуты Пробовал через array, тоже не получается var arr:Array = new Array(); if(var len:uint == myList.excercise.children().length()) { trace('end test'); return; } if (answerTxt.text.toLowerCase() == myList.excercise[question_id].answer) { for(question_id < len; question_id++;){ arr[question_id] = myList.excercise.children()[question_id]; } questionTxt.text = myList.excercise[question_id].question; } Допер короче, сделал так: public class list extends MovieClip { var myFile:String; var xmlLoader:URLLoader; var myList:XML; var randomSelection:uint; public function list() { myFile = "myList.xml"; loadXml(); } public function randomMy(){ var n:uint; var myArray = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18); trace(myArray); n = 3; for (var i:Number = 0; i < n; i++) { randomSelection = Math.floor((Math.random() * myArray.length)); //myArray.splice(randomSelection, 0); } } function loadXml():void { xmlLoader = new URLLoader(new URLRequest(myFile)); xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded); } function xmlLoaded(e:Event):void { myList = new XML(e.target.data); myList.ignoreWhite = true; questionTxt.text = myList.excercise[randomSelection].question; checkBtn.addEventListener(MouseEvent.MOUSE_DOWN, checkAnswer); } function checkAnswer (e:MouseEvent):void { if(randomSelection == myList.excercise.length()) { trace('end test'); return; } if (answerTxt.text == myList.excercise[randomSelection].answer) { randomMy(); questionTxt.text = myList.excercise[randomSelection].question; trace ("correct"); } else { trace ("wrong"); } } } Последний раз редактировалось AlexTrin; 21.05.2013 в 18:37. |
![]() |
![]() |
Часовой пояс GMT +4, время: 05:03. |
|
|
« Предыдущая тема | Следующая тема » |
|
|