Hi Kiran, Please find the code snippet below. The function of interest is "updateVisibleMenuItems". Based on certain condition it tries to enable/disable one menuitem or other. In future there may be more menuitems and the conditions may get complex, but this in essence reflects what I am trying to implement.
As you can see, I have tried both the approaches: 1. Trying to change the XML structure 2. Get an individual menuItem and set its enable/visible property to false. Regards, Kapil <?xml version="1.0" encoding="utf-8"?> <mx:MenuBar xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" change="onItemClick(event)" chromeColor="{Palette.RED}" creationComplete="init()" > <fx:Declarations> <!-- Place non-visual elements (e.g., services, value objects) here --> </fx:Declarations> <fx:Script> <![CDATA[ private function init():void { updateVisibleMenuItems(); } private function onItemClick(event:MenuEvent):void { updateVisibleMenuItems(); } private function updateVisibleMenuItems():void { var menuItem:MenuBarItem = null; var menu_item_1:MenuBarItem = getMenuByID("menuItem1"); var menu_item_2:MenuBarItem = getMenuByID("menuItem2"); if(condition1) { //menuBarXML.menuitem.(@id=="menuItem1").@enabled = "false"; //menuBarXML.menuitem.(@id=="menuItem2").@enabled = "true"; menu_item_1.visible = false; menu_item_1.enabled = false; menu_item_2.visible = true; } else { //menuBarXML.menuitem.(@id=="menuItem1").@enabled = "true"; //menuBarXML.menuitem.(@id=="menuItem2").@enabled = "false"; menu_item_1.visible = true; menu_item_2.visible = false; menu_item_2.enabled = false; } } private function getMenuByID(id:String):MenuBarItem { var menuItem:MenuBarItem = null; for(var i:uint = 0; i < this.menuBarItems.length; ++i) { menuItem = this.menuBarItems[i] as MenuBarItem; if(menuItem.id == id) { break; } } return menuItem; } ]]> </fx:Script> <fx:XMLList id="menuBarXML"> <menuitem id="menuItem1" label="Label1"></menuitem> <menuitem label="|" /> <menuitem id="menuItem2" label="Label2"></menuitem> <menuitem label="|" /> </fx:XMLList> </mx:MenuBar> On Mon, May 30, 2011 at 1:27 PM, kiran reddy <[email protected]> wrote: > Hi, > > It is not possible to explain you without seeing your code.Because where > you went wrong we cant imagine so please paste your code. > > > Kiran. > > On Sun, May 29, 2011 at 1:40 PM, kapil kaushik <[email protected]>wrote: > >> Hi All, >> >> I am trying to hide a menu item at runtime in Flex4, but even if I find >> the relevant menuBarItem and do "item.visible = false" or "item.enabled = >> false", it does not work. >> Any comments/suggestions?? >> >> Thanks, >> Kapil >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Flex India Community" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/flex_india?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Flex India Community" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/flex_india?hl=en. > -- You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/flex_india?hl=en.

