The XML data providers are going to be very different in the next drop you get so it’s hard to say what the right thing to do there is.  I think setProperty should have done it, so re-assigning the dataProvider is probably your workaround for this release.

 

Matt

 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of nicolasberney
Sent: Wednesday, December 28, 2005 11:12 AM
To: [email protected]
Subject: [flexcoders] Dynamically change the root label of a MenuBar

 

Hi,
I'm trying to dynamically change the root label of a MenuBar.
I had to use: "menuBar.dataProvider = menuBar.dataProvider;" to see my changes, but now there is no sub-menus anymore.
Is it the right way to do this with Flex 2?
Thanks,
Nicolas

<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*">
    <mx:Script>
        <![CDATA[
            // Import the MenuEvent class.
            import mx.events.MenuEvent;
       
            // Function that will change the "Root" label to "Has been changed"
     &n! bsp;      // when selecting any sub-menu
            private function changeEvt(event:MenuEvent):Void {
                event.menuItem.getParent().getParent().setProperty("label", "Has been changed", true);
                // I had to do this to see the new label
                menuBar.dataProvider = menuBar.dataProvider;
            }
        ]]>
    </mx:Script>
   
    <mx:XML id="menuData">
        <node label="Root">
     &! nbsp;      <node label="Level 1"&g! t;
&n bsp;               <society label="Level 11" />
                <society label="Level 12" />
            </node>
            <node label="Level 2">
                <society label="Level 21" />
                <society label="Level 22" />
            </node>
        </node>
    </mx:XML>
   
    <mx:MenuBar id="menuBar" dataProvider="{menuData}" change="change! Evt(event)" />
   
</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




Reply via email to