Michael,

Thanks for your timely response.  It does clear up a few things.  My comment about the XML approach being more supported was an (admittedly) obscure reference to my own experiments with the ITreeDataDescriptor interface.  It again goes back to visually updating the Tree.  If the dataProvider is XML, I can edit the XML objects directly and the changes are reflected in the Tree.  However, if the dataProvider is a nested Object (with "children" fields), how does the Tree get notified if the data is changed?  Do we manually call the notifyItemUpdate() method?

Anyway, below is a simple MXML file that demonstrates the bugs I saw with the Tree.  It opens the root node on startup.  Click "Add to root" to add a child to the root node.  An empty row will show up.  Click "Add to child" to try to add a child to Child2.  It crashes my browser.

-----------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml " xmlns="*" layout="absolute" width="431" height="340">
    <mx:Script>
        <![CDATA[
            private var rootNode: XML;
           
            private function init(): void
            {
                rootNode = mytree.dataProvider[0].children()[0];
                mytree.setIsOpen(rootNode, true);               
            }
           
            private function addToRoot(): void
            {
                rootNode.appendChild(<node label="Child3"/>);
            }
           
            private function addToChild(): void
            {
                var child2: XML = rootNode.children()[1];
                trace(child2.toXMLString());   //Sanity check
                child2.appendChild(<node label="Child4"/>);
            }
        ]]>
    </mx:Script>

    <mx:Tree id="mytree" rootVisible="false" x="10" y="10" width="296" height="192" labelField="@label" creationComplete="init()">
        <mx:dataProvider>
            <mx:XML format="e4x">
                <node label="Root">
                    <node label="Child1"/>
                    <node label="Child2"/>
                </node>               
            </mx:XML>           
        </mx:dataProvider>
    </mx:Tree>
       
    <mx:Button x="10" y="210" label="Add to root" click="addToRoot()" />
    <mx:Button x="107" y="210" label="Add to child" click="addToChild()"/>
</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