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?
UPDATE: I found an update similar to what I want to do, it can be found on the following page:
http://blog.flexmonkeypatches.com/2007/10/08/flex-rounded-menues-using-masking/comment-page-1/
The only difference is that I'm showing the Menu with a PopUpButton. So far this is what I have for my custom Menu:
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;
}
}
}
}
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.
When I load my example the:
addEventListener("menuShow", onMenuShow);
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.
Any help on this is appreciated.
Thank you