When you do this:

xmllMenu1 = new XMLList(xmlMenu1 as XML);

what are you trying to get?  An XMLList with a single node?  Why the 'as"?
xmlMenu1 is already XML

 

One almost never uses "new" with XMLList.  Again, what do you want?

 

Also, why are you wanting to use XMLListCollection for the dataProvider
instead of just the root XMLNode?  Collections are essentially linear, but
Tree and XML are essentially hierarchical.

 

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of Keith
Sent: Wednesday, April 08, 2009 8:45 PM
To: [email protected]
Subject: Re: [flexcoders] XML issue driving me nuts

 






For the first one, try pointing the source property to the "node" XMLList.
Before it was pointing to an XML datatype.

<mx:XMLListCollection id="xmllcMenu1" source="{xmllMenu1.node}"/> 

-- Keith H -- 
www.keith-hair. <http://www.keith-hair.net> net 






elevight wrote: 

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. <http://www.adobe.com/2006/mxml>
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