If you run the code below, expand the folder, select a file, and click "add to list" repeatedly, items get added to both dataProviders, but I don't understand why the original tree is changing because I'm not adding items to it.  Could someone explain what's happening?  I'm less interested in fixing it than in understanding what's happening.  Thanks.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" height="400" creationComplete="init()">
   
    <mx:Script>
    <![CDATA[
        import mx.collections.XMLListCollection;
        import mx.collections.ArrayCollection;
   
        [Bindable]
        public var myData:XML=
            <catalog>
                <category name="Folder">
                    <product name="file 1"/>
                    <product name="file 2"/>
                    <product name="file 3"/>
                </category>
            </catalog>;

        [Bindable]
        public var listDP:XMLListCollection = new XMLListCollection(new XMLList());
       
        [Bindable]
        public var testDP:XMLListCollection = new XMLListCollection( new XMLList( myData.children() ) );       
   
        // Add the item selected in the Tree to the List XMLList data provider.
        private function doTreeSelect():void
        {
            if (prodTree.selectedItem)
                listDP.addItem(prodTree.selectedItem);
               
            trace( myData );
            trace( "****************" );
            trace( listDP.source );
        }

    ]]>
    </mx:Script>
   
    <mx:Tree id="prodTree" dataProvider="{testDP}" width="200" showRoot="true" labelField="@name"/>
       
    <mx:HBox>
        <mx:Button id="treeSelect" label="Add to List" click="doTreeSelect()"/>
    </mx:HBox>
       
    <mx:List id="prodList" dataProvider="{listDP}" width="200" labelField="@name"/>

</mx:Application>
__._,_.___

--
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