My short test code is down at the bottom after my description of the problem.

My object is to populate two mx:Tree objects. In my short code sample below, 
only the second tree is getting populated. Can anyone tell me what I'm doing 
wrong with the first mx:Tree?

In summary, both mx:Tree objects use XMLListCollection objects as their 
dataProviders. Both XMLListCollection objects' sources are XMLList objects. 
Both XMLList objects are populated with the same identical XML data. The only 
difference is that one XMLList object gets its XML data from an inline XMLList 
definition, while the other is from an inline XML definition which is passed to 
an XMLList. This subtle difference causes the first mx:Tree not to show 
anything, while the second does. What am I doing wrong?

Thanks in advance.

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

        <mx:Script>
                <![CDATA[
                        import mx.events.ListEvent;
                        
                        private var xmllMenu1:XMLList;
                        
                        private function init():void
                        {
                                //Here's how I'm populating the first XMLList 
object
                                xmllMenu1 = new XMLList(xmlMenu1 as XML);
                        }
                        
                        private function 
treeMenuChangeHandler(event:ListEvent):void
                        {
                                trace("label=" + 
event.target.selectedit...@label +
                                          (event.target.selectedit...@id == 
undefined ? "" : " id=" + event.target.selectedit...@id));
                        }
                ]]>
        </mx:Script>
        
        <mx:XML xmlns="" id="xmlMenu1">
                <node>
                        <node label="Test"/>
                </node>
        </mx:XML>
        
        <!-- Here's how I'm populating the second XMLList object -->
        <mx:XMLList xmlns="" id="xmllMenu2">
                <node>
                        <node label="Test"/>
                </node>
        </mx:XMLList>
        
        <mx:XMLListCollection id="xmllcMenu1"
                source="{xmllMenu1}"/>
                
        <mx:XMLListCollection id="xmllcMenu2"
                source="{xmllMenu2}"/>
        
        <mx:HBox>
                <mx:Tree id="treeMenu1"
                        width="300" height="100%"
                        dataProvider="{xmllcMenu1}"
                        labelField="@label"
                        showRoot="false"
                        change="treeMenuChangeHandler(event)"/>
                        
                <mx:Tree id="treeMenu2"
                        width="300" height="100%"
                        dataProvider="{xmllcMenu2}"
                        labelField="@label"
                        showRoot="false"
                        change="treeMenuChangeHandler(event)"/>
        </mx:HBox>
        
</mx:Application>


Reply via email to