3 Replies Latest reply on Jan 5, 2011 2:58 AM by samiwxx23

    FlexMenubar- submenu item renderer issues..

    Ling's Level 1

      Hi.,

       

      I'm trying to create a custom itemrenderer for the sub menus of an
      itemrenderer, but i'm running into some issues...the main one being that
      I cannot seem to access the sub menus to create them.

       

      ExtendedMenuBar.as

      package com.istmanagement.vo
      {
           import mx.controls.*;
          import mx.controls.Menu;
          import mx.controls.MenuBar;
          import mx.core.ClassFactory;
           public class ExtendedMenuBar extends   MenuBar
             
          {
                public function ExtendedMenuBar()
                 
              {
                  super();
             
              }

               override public function getMenuAt(index:int):Menu
                 
              {          
                  var menu:Menu = super.getMenuAt(index);
               menu.itemRenderer = new ClassFactory(MyMenuBArItem);
                 return menu;
               
              }
         
      }
      }

       

      MyMenuBArItem.as

      package com.istmanagement.vo
      {
         
          import mx.collections.ArrayCollection;
          import mx.controls.Image;
          import mx.controls.Text;
          import mx.controls.menuClasses.MenuBarItem;
          import mx.controls.menuClasses.MenuListData;
          import mx.rpc.events.ResultEvent;
          import mx.controls.Menu;

       

         
         
          public class MyMenuBArItem extends  Menu
          {
              private var image:Image;
              private var imgtest:Image;
              private var text:Text;
             
              public function MyMenuBArItem()
              {
              }
                 
              override protected function commitProperties():void
              {
                  super.commitProperties();
                 
                  var icon:String = data.menuIcon;
                  image = new Image();
                  image.source = icon;
                  addChild(image);
              }
              
              }

       

              override protected function measure():void
              {
                  super.measure();
                 
                  if (image)
                  {
                      measuredWidth += image.measuredWidth +2;
                      measuredHeight = Math.max(image.measuredHeight, measuredHeight);
                  }
              }
             
              override protected function updateDisplayList(unscaledWidth:Number,
                                                            unscaledHeight:Number):void
              {
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
                 
                  if (image)
                  {
                      image.x = (20 - image.measuredWidth) / 2;
                      image.setActualSize(image.measuredWidth, image.measuredHeight);
                      //label.x = 20;
                  }
              }
          }
      }

       

      how to solve this problem.,

       

      any one help me...

       

      With Regards.,

      Lings