Use the dataDescriptor for the tree- here is an example from some base
code i posted earlier about selecting a tree node item - but the jist of
it is :

var xm:ITreeDataDescriptor=myTree.dataDescriptor;
xm.addChildAt(treeData.node.node[0]," <node label='BitchWhoCodes'/>",0);

FULL CODE FOLLOWS :)
,,-------------------------------------------

<?xml version="1.0" encoding="utf-8"?>
<!-- Tree control example. -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >

    <mx:Script>
        <![CDATA[
              import mx.controls.List;
              import mx.collections.ICollectionView;

              import mx.collections.*;

            import       mx.controls.treeClasses.*;
            [Bindable]
            public var selectedNode:Object;

            [Bindable]
            public var XLC:XML;


            // Event handler for the Tree control change event.
            public function initApp(){


            var xm:ITreeDataDescriptor=myTree.dataDescriptor;
            var xml:XMLListCollection=new XMLListCollection(treeData);

             myTree.expandItem(treeData.node[0],true,false);
             myTree.expandItem(treeData.node.node[0],true,false);
             xm.addChildAt(treeData.node.node[0]," <node
label='BitchWhoCodes'/>",0);

            var item=treeData.node.node[0];
            myTree.selectedItem=item;


            }

            public function treeChanged(event:Event) : void
            {
                selectedNode=Tree(event.target).selectedItem;
            }
        ]]>
    </mx:Script>

    <mx:XMLList id="treeData">
        <node>
        <node label="Mail Box">
            <node label="Inbox">
                <node label="Marketing"/>
                <node label="Product Management"/>
                <node label="Personal"/>
            </node>
            <node label="Outbox">
                <node label="Professional"/>
                <node label="Personal"/>
            </node>
            <node label="Spam"/>
            <node label="Sent"/>
        </node>
    </node>
    </mx:XMLList>

    <mx:Panel title="Tree Control Example" height="75%" width="75%"
        paddingTop="10" paddingLeft="10" paddingRight="10"
paddingBottom="10">

        <mx:Label text="Select a node in the Tree control."/>

        <mx:HDividedBox width="100%" height="100%">
            <mx:Tree id="myTree" width="50%" height="100%"
labelField="@label"
                showRoot="false" dataProvider="{new
XMLListCollection(treeData)}" change="treeChanged(event)"
creationComplete="initApp()"/>
            <mx:TextArea height="100%" width="50%"
                text="Selected Item: [EMAIL PROTECTED]"/>
        </mx:HDividedBox>

    </mx:Panel>
</mx:Application>

> Hi,
>
> As you can see below, I solved the problem.
>
> private function addChildAtTree ():void
>  {
>   var foo:XMLList = capitalColl.children ();
>   var foo_0 :XMLList = foo[0].children();
>   var fooColl :XMLListCollection = new XMLListCollection ( foo_0 );
> fooColl.addItem ( new XML ( "<capital label='ME' value='Augusta'/>" )
> );
Tree2.invalidateList();
>  }
>
> But I wanna know if you have any idea other.
>
> Let me know it.
>
> Thank you,
> Bryan.
>   ----- Original Message -----
>   From: Bryan Choi
>   To: flexcoders
>   Sent: Tuesday, May 23, 2006 12:02 PM
>   Subject: [flexcoders] [BETA3] I am still having a problem.
>
>
>   var foo:XMLList = capitalColl.children ();
>   foo.appendChild(new XML ( "<capital label='ME' value='Augusta'/>"));
>
>   ================================================
>
>   I tried to execute it.
>
>   I can see that it show me follow message.
>
>   -------------------
>
>   TypeError: Error #1086: The appendChild method only works on lists
> containing one item.
>
>   -------------------
>
>   Have you Any idea other?
>
>   Thank you,
>   Bryan.
>
>
>   --
>   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
>
>     a..  Visit your group "flexcoders" on the web.
>
>     b..  To unsubscribe from this group, send an email to:
>      [EMAIL PROTECTED]
>
>     c..  Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service.
>
>
> ------------------------------------------------------------------------------
>





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