Your example is working as expected. The reason you get no output is because the xml node you select has no subelements there for the trace is empty. Trace the label property and you will see you are indeed accessing the xml correctly.

 

Change your test xml to something glike this

 

<mx:XML format="e4x" id="myXML" >

                        <category label="Element 1" >

                                    <section label="hello"/>

                        </category>

                        <category label="Element 2" />

</mx:XML>

 

And your dataprovider to dataProvider="{myXML}"

 

 

Add the following to your showNode Method

private function showNode()

  {

trace("node = " + myTree.selectedItem);

trace("attribute = " + [EMAIL PROTECTED]);

  }

 

 

--

Emile Swain

Senior Creative Developer

Direct: 020 7087 2754


From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Brendan Meutzner
Sent: 03 February 2006 14:23
To: flexcoders@yahoogroups.com
Subject: [flexcoders] 2.0 Beta Tree.selectedNode

 

Hi,

I'm obviously missing something, and am hoping someone can fill in the
gap.  I have an XML structure using the e4x format... I'm using this
structure as the dataProvider for a Tree component... I'm trying to
examine the XML element that represents a given tree node.  So...

<mx:XML format="e4x" id="myXML">
  <category label="Element 1" />
  <category label="Element 2" />
</mx:XML>

<mx:Tree id="myTree" dataProvider="{myXML.category}" />
<mx:Button label="Show" click="showNode()" />

<mx:Script>
<![CDATA[
  private function showNode()
  {
    trace("node = " + myTree.selectedNode);
  }
]]>
</mx:Script>


What I'd like it to have returned is eg. "<category label="Element 1"
/>"  However, I not receiving anything from the code above.  The
strange thing is that If I expand my showNode function to show
"[EMAIL PROTECTED]" I am actually getting the proper label as
a result.  The whole purpose of this exercise is to add children to a
selected node, by inserting a child element within the XML structure,
and I need the selected node to determine the parent node of my new child.

I tried this in 1.5, and got mediocre results.  It would return the
proper node result for a branch node, but still return nothing for any
leaf nodes. 

Is what I'm expecting possible, am I asking too much, or is this
perhaps a bug (based on the 1.5 behaviour)?

Thanks in advance,

Brendan










--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to