Probably a bug. Please file a simple test case.
________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Ashton Sent: Wednesday, May 14, 2008 8:03 AM To: [email protected] Subject: [flexcoders] Re: Adding a node to xml document updates tree's dataprovider Any ideas on this one? --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Steve Ashton" <[EMAIL PROTECTED]> wrote: > > Also, I've tracked down the location where the dataprovider changes. > It is HierarchicalCollectionView:812 => children.source = > parentNode.*; > > > --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , "Steve Ashton" steve.ashton@ > wrote: > > > > > > I've got a tree which, as it's dataprovider, uses a child of an xml > > document. When I add a new node as a child of the tree's > dataprovider, > > the dataprovider is reassigned and becomes an XMLList containing > all the > > siblings of the original dataprovider. It works as expected in Flex > > 2.0.1 Hotfix 3. I see the error using Flex Builder 3. > > > > Does anyone know if I am accessing/updating the xml in an incorrect > way? > > Or is this a bug that needs to be logged? > > > > > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " > > > <mx:Button label="Load DP" click="addDP()" /> > > <mx:Button label="Add Node" click="addNode()" /> > > <mx:Tree id="tree" dataProvider="{foo}" labelField="@label" > > width="300" height="300" /> > > > > <mx:Script><![CDATA[ > > import mx.collections.XMLListCollection; > > private var rootXML:XML= > > <Node label='Root'> > > <Node label='Foo' /> > > <Node label='Bar' /> > > <Node label='Baz' /> > > </Node>; > > > > // Use this function to execute the databinding on the tree > > private function addDP():void { > > dispatchEvent(new Event('dpLoaded')); > > } > > > > [Bindable("dpLoaded")] > > private function get foo():XMLListCollection { > > return new XMLListCollection( new XMLList( > rootXML.child(0) > > ) ); > > } > > > > > > private function addNode():void { > > var dp:XMLListCollection = > > XMLListCollection(tree.dataProvider); > > var root:XML = dp.getItemAt( 0 ) as XML; > > var coll:XMLListCollection = new XMLListCollection( > > root.children() ); > > coll.addItem( <Node label='New Node' /> ); > > } > > ]]></mx:Script> > > > > </mx:Application> > > >

