Would anyone have an idea on how to use a variable as the label?  It 
seems that since the node is an object I can't force a string 
concatenation over it.  I'd like to replace...

newNode = <folder label='Sibling'></folder>

With....

newNode = <folder label='strSomeVariable'></folder>

Thanks,




--- In flexcoders@yahoogroups.com, "Jason" <[EMAIL PROTECTED]> wrote:
>
> Thanks for putting me on the right track to being able to add 
items to
> my Tree that is bound to a XMLListCollection.  I had a heck of a 
time
> figuring out how to to an addItemAt to a XMLListCollection ... 
because
> it is not a valid method.  Using the ITreeDataDescriptor was the 
trick.
> 
> I am still not sure how to work this into my UpdateTreeCommand.as 
when
> using Cairngorm.  The code below is a modification of the code you
> posted.  
> 
> [CODE]
> <?xml version="1.0" encoding="utf-8"?>
> <!-- Tree control example. -->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>       creationComplete="init();" >
> 
>       <mx:Script>
>               <![CDATA[
>               import mx.controls.List;
>               import mx.collections.ICollectionView;          
>               import mx.collections.XMLListCollection;        
        
>               import mx.controls.treeClasses.*;               
>               
>               [Bindable]
>               public var selectedNode:Object;
>               
>               [Bindable]
>               public var myXLC:XMLListCollection;
>               //
>               public function init():void{
>                       myXLC = new XMLListCollection(treeData.node);
                        
>               }
>               //
>               public function addMySibling(n:int):void{       
        
>                       var xm:ITreeDataDescriptor = 
myTree.dataDescriptor;  
> 
>                       var newNode:XML = new XML();
>                       newNode = <folder label='Sibling'></folder>
>                       if (n == -1){
>                               myXLC.addItem(newNode);         
                
>                       } else {
>                               xm.addChildAt(myTree.getParentItem
(myTree.selectedItem),newNode,n);       
>                       }
>                       
>               
>               }
>               //
>               public function addMyChild(n:int):void{         
>                       var xm:ITreeDataDescriptor = 
myTree.dataDescriptor;  
>                       
>                       var newNode:XML = new XML();
>                       newNode = <folder label='Child'></folder>
>                       
>                       if (n == -1){
>                               xm.addChildAt
(myTree.selectedItem,newNode,0);
>                       } else {
>                               xm.addChildAt
(myTree.selectedItem,newNode,n);                
>                       }               
>                       /*
>                       // Code to select the newly created child.  
I cannot get this to
> work =(
>                       var selItem:ICollectionView = xm.getChildren
(myTree.selectedItem);
>                       trace("selItem: "+selItem);
>                       trace("selItem.length: "+selItem.length);
>                       myTree.selectedItem = 
myTree.selectedItem.childNodes[selItem.length];
>                       */      
>               }
>               
>               //
>               public function treeChanged(event:Event) : void
>               {
>                       selectedNode=Tree(event.target).selectedItem;
>               }
>               ]]>
>       </mx:Script>
> 
>       <mx:XML 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:XML>
>       
>       <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:Button label="Add sibling to selected tree node"
> click="addMySibling(myTree.selectedIndex)"/>
>               <mx:Button label="Add child to selected tree node"
> click="addMyChild(myTree.selectedIndex)"/>
>               <mx:HDividedBox width="100%" height="100%">
>                       <mx:Tree id="myTree" width="50%" 
height="100%"
>                       labelField="@label"
>                       showRoot="false" dataProvider="{myXLC}" 
>                       change="treeChanged(event)"/>
>                       <mx:TextArea height="100%" width="50%"
>                       text="Selected Item: [EMAIL PROTECTED]"/>
>               </mx:HDividedBox>
>       
>       </mx:Panel>
> </mx:Application>
> [/CODE]
> 
> 
> 
> --- In flexcoders@yahoogroups.com, <stacey@> wrote:
> >
> > 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 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to