472,143 Members | 1,299 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,143 software developers and data experts.

Calling a List of XML Data into a TextArea

4
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

Expand|Select|Wrap|Line Numbers
  1. import fl.controls.ComboBox;
  2. import fl.controls.TextArea;
  3. import fl.containers.UILoader;
  4.  
  5. //Component Style
  6. import fl.managers.StyleManager;
  7.  
  8. var xmlLoader:URLLoader = new URLLoader();
  9. var dataURL:URLRequest = new URLRequest("data.xml");
  10. xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
  11. xmlLoader.load(dataURL);
  12.  
  13. var tFormatHead:TextFormat = new TextFormat();
  14. tFormatHead.bold = true;
  15. tFormatHead.size = 12;
  16. tFormatHead.font = "Arial";
  17.  
  18.  
  19. var albumFormat:TextFormat = new TextFormat();
  20. albumFormat.font = "Arial";
  21. albumFormat.size = 12;
  22. albumFormat.bold = true;
  23.  
  24. //StyleManager.setStyle("textFormat", albumFormat);
  25.  
  26. var dataXML:XML = new XML();
  27. dataXML.ignoreWhitespace = true;
  28.  
  29. // Choose Style Drop-Down
  30. var cbStyle:ComboBox = new ComboBox; // Combobox
  31. cbStyle.x = 755;
  32. cbStyle.y = 260;
  33. cbStyle.width = 100;
  34. addChild(cbStyle);
  35.  
  36. // Choose Style
  37. var tfStyleTxt:TextField = new TextField();
  38. tfStyleTxt.x = 750;
  39. tfStyleTxt.y = 240;
  40. tfStyleTxt.autoSize = TextFieldAutoSize.LEFT;
  41. tfStyleTxt.text = "Choose Style";
  42. addChild(tfStyleTxt);
  43. tfStyleTxt.setTextFormat(tFormatHead);
  44.  
  45. var txtFldPassage:TextArea = new TextArea(); // Text Area Description
  46. txtFldPassage.x = 30;
  47. txtFldPassage.y = 120;
  48. txtFldPassage.width = 700;
  49. txtFldPassage.height = 250;
  50. txtFldPassage.editable = false;
  51. txtFldPassage.condenseWhite = true;
  52. addChild(txtFldPassage);
  53.  
  54.  
  55. var txtFldQuestions:TextArea = new TextArea(); // Text Area City
  56. txtFldQuestions.x = 30;
  57. txtFldQuestions.y = 440;
  58. txtFldQuestions.width = 600;
  59. txtFldQuestions.height = 200;
  60. txtFldQuestions.editable = false;
  61. addChild(txtFldQuestions);
  62.  
  63. var txtFldFeedback:TextArea = new TextArea(); // Text Area feedback
  64. txtFldFeedback.x = 650;
  65. txtFldFeedback.y = 440;
  66. txtFldFeedback.width = 300;
  67. txtFldFeedback.height = 200;
  68. txtFldFeedback.editable = false;
  69. addChild(txtFldFeedback);
  70.  
  71.  
  72. function xmlLoaded(evt:Event):void
  73. {
  74.     dataXML = XML(xmlLoader.data);
  75.  
  76.     for (var tripName:String in dataXML.list)
  77.     {    
  78.         cbStyle.addItem({label:dataXML.list[tripName].@style});
  79.     }
  80.     txtFldPassage.htmlText = dataXML.list[0].passage;
  81.     txtFldQuestions.text = dataXML.list[0].question;
  82.     txtFldFeedback.text = dataXML.list[0].feedback;
  83.  
  84. }
  85.  
  86. function selectStyle(evt:Event):void
  87. {
  88.     trace ("selected" + evt.target.selectedIndex);
  89.     txtFldPassage.htmlText = dataXML.list[evt.target.selectedIndex].passage;
  90.     txtFldQuestions.text = dataXML.list[evt.target.selectedIndex].question;
  91.     txtFldFeedback.text = dataXML.list[evt.target.selectedIndex].feedback;
  92.  
  93.  
  94. }
  95. cbStyle.addEventListener(Event.CHANGE, selectStyle);
  96.  

and here's the XML
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <data>
  3.   <list style="Bold">
  4.     <question>the thing that will turn into a chicken after hatching</question>
  5.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  6.     <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>
  7.   </list>
  8.   <list style="Underline">
  9.     <question>a living creature that is not human</question>
  10.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  11.     <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>
  12.   </list>
  13.   <list style="Bracket">
  14.     <question>small</question>
  15.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  16.     <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>
  17.   </list>
  18.   <list style="Font Color ">
  19.     <question>the seeds of frogs</question>
  20.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  21.     <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>
  22.   </list>
  23.   <list style="All Style ">
  24.     <question>an animal that can live on land and in water</question>
  25.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  26.     <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>
  27.   </list>
  28. </data>
  29.  
  30. <data>
  31.   <list style="Bold">
  32.     <question>the thing that will turn into a chicken after hatching</question>
  33.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  34.     <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>
  35.   </list>
  36.   <list style="Underline">
  37.     <question>a living creature that is not human</question>
  38.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  39.     <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>
  40.   </list>
  41.   <list style="Bracket">
  42.     <question>small</question>
  43.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  44.     <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>
  45.   </list>
  46.   <list style="Font Color ">
  47.     <question>the seeds of frogs</question>
  48.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  49.     <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>
  50.   </list>
  51.   <list style="All Style ">
  52.     <question>an animal that can live on land and in water</question>
  53.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  54.     <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>
  55.   </list>
  56. </data>
  57.  
  58.  
  59. <data>
  60.   <list style="Bold">
  61.     <question>the thing that will turn into a chicken after hatching</question>
  62.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  63.     <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>
  64.   </list>
  65.   <list style="Underline">
  66.     <question>a living creature that is not human</question>
  67.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  68.     <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>
  69.   </list>
  70.   <list style="Bracket">
  71.     <question>small</question>
  72.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  73.     <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>
  74.   </list>
  75.   <list style="Font Color ">
  76.     <question>the seeds of frogs</question>
  77.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  78.     <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>
  79.   </list>
  80.   <list style="All Style ">
  81.     <question>an animal that can live on land and in water</question>
  82.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  83.     <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>
  84.   </list>
  85. </data>
  86.  
  87. <data>
  88.   <list style="Bold">
  89.     <question>the thing that will turn into a chicken after hatching</question>
  90.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  91.     <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>
  92.   </list>
  93.   <list style="Underline">
  94.     <question>a living creature that is not human</question>
  95.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  96.     <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>
  97.   </list>
  98.   <list style="Bracket">
  99.     <question>small</question>
  100.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  101.     <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>
  102.   </list>
  103.   <list style="Font Color ">
  104.     <question>the seeds of frogs</question>
  105.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  106.     <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>
  107.   </list>
  108.   <list style="All Style ">
  109.     <question>an animal that can live on land and in water</question>
  110.     <feedback>I think you got the correct answer. Click the word now to confirm if this is correct</feedback>
  111.     <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>
  112.   </list>
  113. </data>
  114.  
Thanks in advance.
Sep 4 '08 #1
0 2184

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

5 posts views Thread by Andrew V. Romero | last post: by
3 posts views Thread by Gram | last post: by
4 posts views Thread by just1coder | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.