PDA

View Full Version : Tree Component DataProvider...


EndlessLine
05-01-2008, 08:53 PM
I'm under the impression that the tree component creates nodes (branches and leaves) base on the structure it is given from a data provider, in this case XML. The XML document is rendering in my tree but incorrectly, I see the raw XML, how badly am I brain farting here? (xmlData is a XML object)

private function createTree(e:Event):void{
var lessonXMLList:XMLList = new XMLList(lessonXML.xmlData);
tree.percentWidth = 100;
tree.percentHeight = 100;
tree.dataProvider = lessonXMLList;
}

Here is my XML, the pattern just repeats so the first major node should be sufficient

<?xml version="1.0" encoding="UTF-8"?>
<classes>
<lecture name="Math">
<section name="Equations">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Variables">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Legends of Mathematics">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Common Formulas">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
</lecture>
<lecture name="Science">
<section name="Elements">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Compounds">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Legends of Science">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Lab">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
</lecture>
<lecture name="Reading">
<section name="Nouns">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Verbs">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Punctuation">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="MLA Format and Library Cards">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
</lecture>
<lecture name="Spanish">
<section name="Conjugation">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Verbs">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="History of Spain">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="History of Spanish Language">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
</lecture>
<lecture name="Social Studies">
<section name="History of America">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="WWII">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Current Events">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
<section name="Presidential Election">
<lesson name="Lesson 1">
</lesson>
<lesson name="Lesson 2">
</lesson>
<lesson name="Lesson 3">
</lesson>
</section>
</lecture>
</classes>



Whoops....guess I need to be moved to the component section

EndlessLine
05-02-2008, 04:08 PM
got it if anyone else has a similar problem, the "labelField" seemed to do the trick

private function createTree(e:Event):void{
var item:XML;
var lessonXMLList:XMLList = new XMLList(lessonXML.xmlData.children());
tree.labelField = "@name";
tree.percentWidth = 100;
tree.percentHeight = 100;
tree.dataProvider = lessonXMLList;
}