I’m planning to call a list of data from an XML file but when I duplicate the content inside the <data></data> it is not showing anything
Here’s the ActionScript 3.0
import fl.controls.ComboBox;
import fl.controls.TextArea;
import fl.containers.UILoader;
//Component Style
import fl.managers.StyleManager;
var xmlLoader:URLLoader = new URLLoader();
var dataURL:URLRequest = new URLRequest("data.xml");
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
xmlLoader.load(dataURL);
var tFormatHead:TextFormat = new TextFormat();
tFormatHead.bold = true;
tFormatHead.size = 12;
tFormatHead.font = "Arial";
var albumFormat:TextFormat = new TextFormat();
albumFormat.font = "Arial";
albumFormat.size = 12;
albumFormat.bold = true;
//StyleManager.setStyle("textFormat", albumFormat);
var dataXML:XML = new XML();
dataXML.ignoreWhitespace = true;
// Choose Style Drop-Down
var cbStyle:ComboBox = new ComboBox; // Combobox
cbStyle.x = 755;
cbStyle.y = 260;
cbStyle.width = 100;
addChild(cbStyle);
// Choose Style
var tfStyleTxt:TextField = new TextField();
tfStyleTxt.x = 750;
tfStyleTxt.y = 240;
tfStyleTxt.autoSize = TextFieldAutoSize.LEFT;
tfStyleTxt.text = "Choose Style";
addChild(tfStyleTxt);
tfStyleTxt.setTextFormat(tFormatHead);
var txtFldPassage:TextArea = new TextArea(); // Text Area Description
txtFldPassage.x = 30;
txtFldPassage.y = 120;
txtFldPassage.width = 700;
txtFldPassage.height = 250;
txtFldPassage.editable = false;
txtFldPassage.condenseWhite = true;
addChild(txtFldPassage);
var txtFldQuestions:TextArea = new TextArea(); // Text Area City
txtFldQuestions.x = 30;
txtFldQuestions.y = 440;
txtFldQuestions.width = 600;
txtFldQuestions.height = 200;
txtFldQuestions.editable = false;
addChild(txtFldQuestions);
var txtFldFeedback:TextArea = new TextArea(); // Text Area feedback
txtFldFeedback.x = 650;
txtFldFeedback.y = 440;
txtFldFeedback.width = 300;
txtFldFeedback.height = 200;
txtFldFeedback.editable = false;
addChild(txtFldFeedback);
function xmlLoaded(evt:Event):void
{
dataXML = XML(xmlLoader.data);
for (var tripName:String in dataXML.list)
{
cbStyle.addItem({label:dataXML.list[tripName].@style});
}
txtFldPassage.htmlText = dataXML.list[0].passage;
txtFldQuestions.text = dataXML.list[0].question;
txtFldFeedback.text = dataXML.list[0].feedback;
}
function selectStyle(evt:Event):void
{
trace ("selected" + evt.target.selectedIndex);
txtFldPassage.htmlText = dataXML.list[evt.target.selectedIndex].passage;
txtFldQuestions.text = dataXML.list[evt.target.selectedIndex].question;
txtFldFeedback.text = dataXML.list[evt.target.selectedIndex].feedback;
}
cbStyle.addEventListener(Event.CHANGE, selectStyle);
and here’s the XML
<?xml version="1.0" encoding="iso-8859-1"?>
<data>
<list style="Bold">
<question>the thing that will turn into a chicken after hatching</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it come from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Underline">
<question>a living creature that is not human</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it <u>come</u> from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Bracket">
<question>small</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby <i>[frog]</i> grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Font Color ">
<question>the seeds of frogs</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby frog grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="All Style ">
<question>an animal that can live on land and in water</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it <u>come</u> from? How does a baby <i>[frog]</i> grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
</data>
<data>
<list style="Bold">
<question>the thing that will turn into a chicken after hatching</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it come from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Underline">
<question>a living creature that is not human</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it <u>come</u> from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Bracket">
<question>small</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby <i>[frog]</i> grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Font Color ">
<question>the seeds of frogs</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby frog grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="All Style ">
<question>an animal that can live on land and in water</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it <u>come</u> from? How does a baby <i>[frog]</i> grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
</data>
<data>
<list style="Bold">
<question>the thing that will turn into a chicken after hatching</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it come from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Underline">
<question>a living creature that is not human</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it <u>come</u> from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Bracket">
<question>small</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby <i>[frog]</i> grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Font Color ">
<question>the seeds of frogs</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby frog grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="All Style ">
<question>an animal that can live on land and in water</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it <u>come</u> from? How does a baby <i>[frog]</i> grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
</data>
<data>
<list style="Bold">
<question>the thing that will turn into a chicken after hatching</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it come from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Underline">
<question>a living creature that is not human</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it <u>come</u> from? How does a baby frog grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Bracket">
<question>small</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby <i>[frog]</i> grow into an adult frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="Font Color ">
<question>the seeds of frogs</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a baby frog called? Where does it come from? How does a baby frog grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
<list style="All Style ">
<question>an animal that can live on land and in water</question>
<feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
<passage>What is a <b>baby</b> frog called? Where does it <u>come</u> from? How does a baby <i>[frog]</i> grow into an <font color="#FF0000">adult</font> frog? This is the story of the life cycle of the frog.</passage>
</list>
</data>
Thanks in advance.