I'm trying to populate an mx:Tree with an external XML document 
consisting only of nested <node> tags with label and data 
attributes. I'm using the Flex Samples Tree example 
(http://www.macromedia.com/flex/samples/explorer/complib/TreeDemo.mxm
l) as a guide. The Tree displays the XML document contents 
correctly, but when I click on a node, the mx:Label I have to 
display the node's data isn't working. Here's the code:


<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml";>
<mx:Script>
var selectedNode:Object;
</mx:Script>

<mx:Model id="myTree" source="tree.xml"/>

<mx:HBox horizontalGap="30">

<mx:Tree height="200" 
change="selectedNode=event.target.selectedItem.attributes">
<mx:dataProvider>
{myTree}
</mx:dataProvider>
</mx:Tree>

<mx:Panel id="displayPanel" title="I'm a Panel" width="200">
<mx:Label text="{selectedNode.label}" id="myLabel"/>
</mx:Panel>
</mx:HBox>
</mx:Application>


Here is what the XML file looks like:

<node label="Root Node">
<node label="Level 1 Node 1">
<node label="Level 2 Node 1" data="blah1"/>
<node label="Level 2 Node 2" data="blah2"/>
</node>
<node label="Level 1 Node 2" data="blah3"/>
</node>

Any help would be greatly appreciated.

Thanks!



Reply via email to