Everything works through the dataProvider.  First use e4x expressions to
find the node you want to change, then set the attribute.  Below are
some lines from some of my code.  I am only setting enabled and the
label, but the same techniques should work for checkboxes, etc.

 

Tracy

 

      public function set xmlSelectedItem(xml:XML):void

      {

        _xmlSelectedItem = xml;

        var sNodeName:String;

        var sActionType:String;

        var sAction:String;

        var sTemp:String = "";

        var sLabel:String = "";

        var xmlCopiedItem:XML;

        

        if (_xmlSelectedItem)  {

          

          sNodeName = _xmlSelectedItem.name();

          sActionType = [EMAIL PROTECTED];

          sAction = [EMAIL PROTECTED];

          

          xmlMenu..menuitem.(attribute("action") ==
'deleteSelected')[EMAIL PROTECTED] = true;

          xmlMenu..menuitem.(attribute("action") ==
'copySelected')[EMAIL PROTECTED] = true;

          xmlMenu..menuitem.(attribute("action") ==
'addMenuItem')[EMAIL PROTECTED] = true;

          xmlMenu..menuitem.(attribute("action") ==
'addAppItem')[EMAIL PROTECTED] = true;  

          if (sNodeName == "menu")  {

            sTemp = " to '" + [EMAIL PROTECTED] + "'"

          } 

          else  {

           sTemp = " to '" + [EMAIL PROTECTED] + "'";

          } 

        sLabel =  "Add Menu Item" + sTemp;

        xmlMenu..menuitem.(attribute("action") == 'addMenuItem')[EMAIL 
PROTECTED]
= sLabel;

        sLabel =  "Add Application Item" + sTemp;

        xmlMenu..menuitem.(attribute("action") == 'addAppItem')[EMAIL 
PROTECTED] =
sLabel;

...

________________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mike Anderson

Sent: Monday, October 29, 2007 4:15 PM

To: [email protected]

Subject: [flexcoders] Controlling MenuBar Submenus via Code frustrations

 

Greetings All,

 

I've burned an entire DAY searching the web for examples of how to

control sub-menus in a MenuBar control, via code. The main types of

things I need to accomplish, is toggling Checkboxes and Radio Buttons,

when certain application variables change.

 

My MenuBar has 6 primary menus across the top, and each primary menu,

could have any number of additional sub-menus (which have several

variations of menu types - Checkboxes, Radio Buttons, etc.)

 

My MenuBar is being populated via an external XML File.

 

Per the docs, each top level menu is considered a 'MenuBarItem', but

there is very little helpful information after that. All the help docs

focus primarily on listening for MenuBar events and writing functions to

respond - but there is NOTHING on how to do the reverse.

 

I consider myself to be a fairly seasoned Flex Programmer, but this

MenuBar stuff has got me stumped, and quite frustrated.

 

If anybody has any examples on this topic, I would be VERY grateful.

 

Thanks in advance for any help,

 

Mike

 

Reply via email to