OK, since nobody replied, I solved it myself.  Solution is a bit
strange, but basically referring to treeData2[0] works to expand the
first node, while intuitively you might think that it should be
treedData2.node[0].  hmmm...

here's the working code:

---
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
        <mx:Script>
        <![CDATA[                  
            [Bindable]
            private var XLC:XMLList;
                        
            private function initTree() : void
            {
                openTreeNodes();
            }
            private function openTreeNodes():void{
                //open the first two folders in IM tree
                imTree.expandItem(treeData2[0], true, true);
                trace("treeData2.node[0] = "+treeData2[0]);
            }
        ]]>
    </mx:Script>
    <mx:XMLList id="treeData2">
            <node label="Buddies">
                <node label="master" email="[EMAIL PROTECTED]" />
            </node>
            <node label="CoWorkers">
                <node label="Ewoldt"/>
                <node label="Swingler"/>
            </node>
            <node label="Offline">
                <node label ="Bini" />
            </node>   
    </mx:XMLList>

                <mx:Tree id="imTree" width="100%" height="100%" 
labelField="@label"
                        showRoot="false" dataProvider="{treeData2}"
                        creationComplete="initTree()"/>
</mx:Application>

--- In [email protected], "fuad_kamal" <[EMAIL PROTECTED]> wrote:
>
> I can't get expandItem() to work; anyone see the problem in my code? 
> I want to automatically expand the first node on the tree.
> ---
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> layout="absolute">
>       <mx:Script>
>         <![CDATA[
>               
>               import mx.events.ListEvent;
>                          
>             [Bindable]
>             private var XLC:XMLList;
>                       
>             private function initTree() : void
>             {
>               openTreeNodes();
>             }
>             private function openTreeNodes():void{
>               //open the first two folders in IM tree
>               imTree.expandItem(treeData2.node[0], true, true);
>             }
>         ]]>
>     </mx:Script>
>     <mx:XMLList id="treeData2">
>             <node label="Buddies">
>                 <node label="master" email="[EMAIL PROTECTED]" />
>             </node>
>             <node label="CoWorkers">
>                 <node label="Ewoldt"/>
>                 <node label="Swingler"/>
>             </node>
>             <node label="Offline">
>               <node label ="Bini" />
>             </node>   
>     </mx:XMLList>
> 
>               <mx:Tree id="imTree" width="100%" height="100%" 
> labelField="@label"
>                       showRoot="false" dataProvider="{treeData2}"
>                       creationComplete="initTree()"/>
> </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 
Yahoo! Groups Links

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

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