4 Replies Latest reply on May 16, 2010 10:11 PM by -skitch-

    Menubar with icon on right side? Please Help!

    -skitch-

      The standard Flex menubar item renderer puts the icon on the left side with the label extending the rest of the way.  How can I get the icon on the right, with the text centered (in my measure function, I put a constant width for the item).

       

      note: it works if I set the labels actual size in update display list, but if I change the dataprovider in anyway, it does some very unnecessary redrawing (flashing).

       

      some code from my menubar item renderer:

       

      Any help would be greatly appreciated!

       

      override protected function measure():void
              {
                  super.measure();
                 
                  measuredWidth = BAR_WIDTH;
              }
             
              override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
              {
                  super.updateDisplayList(unscaledWidth, unscaledHeight);
             
                  /*label.setActualSize(label.getExplicitOrMeasuredWidth(),
                      label.getExplicitOrMeasuredHeight());*/

                     //Center the label
                  label.y = (unscaledHeight - label.height) / 2;
                  label.x = (unscaledWidth - label.width) / 2;

                     //Add icon
                  if(downArrowImage != null)
                  {
                      downArrowImage.y = (unscaledHeight - downArrowImage.height)/2;
                      downArrowImage.x = arrowSpacer + label.x + label.width;
                  }
              }