1 Reply Latest reply on Apr 25, 2010 9:28 AM by -skitch-

    Changing enabled properties of children in a Menu of a Menubar

    -skitch- Level 1

      Hey everyone,

       

      I have this issue where I'm trying to set the enabled property of an item in one of the menus of a Menubar WITHOUT changing the data provider.  If you change the actual data provider (XMLList) this fires off bindings and actually redraws the Menubar component giving it a flickering effect which I really don't want.  You can enable/disable the top level menuBarItems by menuBarItems[X].enabled (which doesn't change the dataprovider), but I need to change the enabled property of an item in one of the popup menus. The update to the property happens quite often and causes the flickering constantly.

       

      In my set hasAsset method, this is where I would like the enable configuration to happen.  I have tried alot of proposed solution, but nothing yet...

       

      Any help at all would be great!

       

      The code is below:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:MenuBar
          xmlns:mx="http://www.adobe.com/2006/mxml"
          dataProvider="{menuItems}"
          itemClick="itemClickHandler(event)"
          labelField="@label"
          styleName="MainNaviMenu">
         
          <!-- Here is the static list of views in the MainMenu -->
          <mx:XMLList id="menuItems">
              <menuitem label="Asset Manager">
                  <menuitem label="Map Files" view="ShowIngestion" subview="ShowMap"/>
                  <!-- This is coming out with this iteration, commenting out for now. --> 
                  <!-- <menuitem label="Replace Master" view="ShowIngestion" subview="ShowReplace"/> -->
                  <menuitem label="Metadata" view="ShowIngestion" subview="ShowAsset"/>
                  <menuitem label="Metaframe" view="ShowIngestion" subview="ShowMetaFrame"/>
                  <menuitem label="Thumbs" view="ShowIngestion" subview="ShowThumbEditor"/>
                  <menuitem label="Clips" view="ShowIngestion" subview="ShowClips"/>
                  <menuitem label="Preview" enabled="false" view="ShowPreview"/>
              </menuitem>
              <menuitem label="Publisher">
                  <menuitem label="Schedule" view="ShowScheduling"/>
              </menuitem>
              <menuitem label="Intelligence" enabled="false">
                  <menuitem label="Drilldown" view="ShowDrilldown"/>
              </menuitem>
              <menuitem label="Administration" enabled="false">
                  <menuitem label="Users" view="ShowAdminUsers"/>
                  <menuitem label="Folders" view="ShowAdminFolders"/>
                  <menuitem label="Tracks" view="ShowAdminTracks"/>
                  <menuitem label="SmartFeeds" view="ShowAdminSmartfeeds"/>
                  <menuitem label="Categories" view="ShowAdminCategories"/>
                  <menuitem label="Playlist" view="ShowAdminPlaylists"/>
              </menuitem>
          </mx:XMLList>
         
          <!-- Bindings -->
          <mx:Binding
              source = "{model.selectedAsset != null}"
              destination = "hasAsset"/>
         
          <mx:Binding
              source = "model.user.isAdminOrSystem"
              destination = "isAdmin"/>
         
          <mx:Binding
              source = "{model.user.organizationReportingEnabled &amp;&amp; model.drilldownCollection.distributorHierarchy != null}"
              destination = "organizationReportingEnabled"/>
         
          <mx:Script>
              <![CDATA[
                  import com.digitalsmiths.cms.events.SelectViewEvent;
                  import com.digitalsmiths.cms.model.ActiveUser;
                  import com.digitalsmiths.cms.model.CMSModel;
                 
                  import mx.collections.XMLListCollection;
                  import mx.controls.Menu;
                  import mx.controls.menuClasses.IMenuBarItemRenderer;
                  import mx.controls.menuClasses.MenuBarItem;
                  import mx.events.FlexEvent;
                  import mx.events.MenuEvent;
                 
                  [Bindable]
                  public var model:CMSModel = CMSModel.getInstance();
              
                  public function set hasAsset (value:Boolean):void
                  {

                     //THE FIX GOES HERE
                  }
                 
                  public function set isAdmin (value:Boolean): void
                  {
                      menuBarItems[3].enabled = value;
                  }
                 
                  public function set organizationReportingEnabled(value:Boolean): void
                  {
                      menuBarItems[2].enabled = value;
                  }
              ]]>
          </mx:Script>
         
      </mx:MenuBar>