title: Flex 3: Rounded Menu with a PopUpButton
body: <p>So I have a PopupButton and when I click on the button I want the Menu that pops up to have rounded corners. How would I go about doing this?</p>
  
  <p>UPDATE:
  I found an update similar to what I want to do, it can be found on the following page:</p>
  
  <p><a href="http://blog.flexmonkeypatches.com/2007/10/08/flex-rounded-menues-using-masking/comment-page-1/" rel="nofollow noreferrer">http://blog.flexmonkeypatches.com/2007/10/08/flex-rounded-menues-using-masking/comment-page-1/</a> </p>
  
  <p>The only difference is that I'm showing the Menu with a PopUpButton.  So far this is what I have for my custom Menu:</p>
  
  <pre><code>package {
  
      import flash.display.Sprite;
  
      import mx.controls.Menu;
      import mx.events.MenuEvent;
  
      public class MyMenu extends Menu {
  
          public function MyMenu() {
              super();
              addEventListener("menuShow", onMenuShow);
          }
  
          private function onMenuShow(e:MenuEvent):void {
              callLater(maskRoundedCorners,[e]);
          }
  
  
       private function maskRoundedCorners(e:MenuEvent):void {
  
                  var menu:Menu = e.menu as Menu;
                  menu.cacheAsBitmap=false;
  
                  if (!menu.mask){
                      var maskx:uint = menu.x;
                      var masky:uint = menu.y;
                      var maskw:uint = menu.getExplicitOrMeasuredWidth();
                      var maskh:uint = menu.getExplicitOrMeasuredHeight();
                      var rad:int = menu.getStyle("cornerRadius") * 2;
  
                      var roundRect:Sprite = new Sprite();
                      roundRect.graphics.beginFill(0xFFFFFF);
                      roundRect.graphics.drawRoundRect(maskx,masky,maskw,maskh,rad);
                      roundRect.graphics.endFill();
                      menu.mask = roundRect;
              }
          }  
      }
  }
  </code></pre>
  
  <p>Can anyone help me out with what I'm missing...I'm not sure if i need to override any of the Menu classes functions.</p>
  
  <p>When I load my example the:</p>
  
  <p>addEventListener("menuShow", onMenuShow);</p>
  
  <p>gets fire but when i click the PopUpButton to show the menu the onMenuShow function is not being fired and the regular menu is being display with out the rounded corners.</p>
  
  <p>Any help on this is appreciated.</p>
  
  <p>Thank you</p>