Hi Josh,

 

You're using a Model which doesn't distinguish between attributes and child properties.  So I think you can do this:

 

<mx:Tree height="200"
change="selectedNode=event.target.selectedItem ">

 

Then hopefully the rest will work.

 

Matt

-----Original Message-----
From: joshbronson630 [mailto:[EMAIL PROTECTED]
Sent:
Monday, May 03, 2004 10:03 AM
To: [EMAIL PROTECTED]
Subject: [flexcoders] populating tree with external xml

 

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="">
    <node label="Level 2 Node 2" data="">
  </node>
  <node label="Level 1 Node 2" data="">
</node>

Any help would be greatly appreciated.

Thanks!



Reply via email to