Flex 3:带有 PopUpButton 的圆形菜单
所以我有一个 PopupButton,当我单击该按钮时,我希望弹出的菜单具有圆角。我该怎么做呢?
更新: 我发现了与我想要做的类似的更新,可以在以下页面上找到:
http://blog.flexmonkeypatches.com/2007/10/08/flex-rounded-menues-using-masking/comment-page-1/
唯一的区别是我用 PopUpButton 显示菜单。到目前为止,这就是我的自定义菜单:
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;
}
}
}
}
任何人都可以帮助我解决我所缺少的内容...我不确定是否需要覆盖任何菜单类功能。
当我加载示例时:
addEventListener("menuShow", onMenuShow);
发生火灾,但当我单击 PopUpButton 显示菜单时, onMenuShow 函数不会被触发,并且常规菜单显示时没有圆角。
对此的任何帮助表示赞赏。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
终于明白了这一点。这是我想出的解决方案:
如果您有更好的解决方案,请评论。
Finally figured this out. Here is the solution that I came up with:
If you happen to have a better solution please comment.