This is a known bug.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of deh_ats
Sent: Monday, May 28, 2007 3:39 AM
To: [email protected]
Subject: [flexcoders] Tree and XML data containing two similar text
nodes

 

Hi there,

There must be something terribly wrong with the Tree component. Here
is a very basic Flex app sample in which I try to have a Tree
component render some very basic XML data.

The thing is that in this XML, two text nodes have the same value ("a"
in my exemple). I can't see why this would be any problem. However,
when you fully expand the Tree, you'll notice that you just can't
rollOver and select one of the nodes. You may rollOver and select a
first node, but when trying to roll over the other one, the Tree
highlights the other node, and you cannot select it at all!

It looks like for the Tree, there was only one XML instance for this
text node, and that both itemRenders rendered this same object.

I understand this might have to do with the fact that XML objects are
compared by value, not by reference (unlike as2 XMLNodes if I remember
correctly):

var n1:XML=new XML(<item/>);
var n2:XML=new XML(<item/>);
trace(n1==n2);// output:true

Note that this is just one of the numerous bugs I encountered when
dealing with the Tree component and XML. But I chose to post on this
one because it's pretty basic.

Any help or comment would be much appreciated!

Please tell me that I got something wrong and that the Tree component
isn't actually broken...

:)

Here's the MXML (bug found when compiled with Flex Builder 2.0.1, Mac
OSX and Win XP. Hotfix2 didn't fix anything): 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
layout="absolute">

<mx:Script>
<![CDATA[
import mx.utils.UIDUtil;

[Bindable]
public var xmlData:XML = <root><item1>a</item1><item2>a</item2></root>;

// this is just to display something
public function labelFunc(item:Object):String
{
return "node"; 
}

]]>
</mx:Script>
<mx:Tree dataProvider="{xmlData}" labelFunction="labelFunc" x="10"
y="10" width="245" height="204"></mx:Tree>

</mx:Application>

 

Reply via email to