我正在使用 Flash Builder 4 并且正在学习中。
简短的解释是,我想要一个标签导航器,其标签如下所示:
我知道我可以使用基于图像的皮肤来做到这一点,但我认为(并且可能是错误的)以编程方式绘制形状在可扩展性方面会更好。
只要我得到我正在寻找的结果,我想我真的不在乎它是 mx 还是 spark。我试过这样做:
主应用:
<mx:ButtonBar dataProvider="{vsTabNav}" firstButtonStyle="firstButtonStyle"/>
CSS 文件:
.firstButtonStyle { skinClass:ClassReference("assets.skins.ButtonBarFirstButtonSkin"); }
ButtonBarFirstButtonSkin.as:
package assets.skins
{
import flash.display.Graphics;
import mx.skins.halo.ButtonBarButtonSkin;
import mx.graphics.RectangularDropShadow;
public class ButtonBarFirstButtonSkin extends ButtonBarButtonSkin
{
private var dropShadow:RectangularDropShadow;
public function ButtonBarFirstButtonSkin()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
var cornerRadius:Number = getStyle("cornerRadius");
var backgroundColor:int = getStyle("backgroundColor");
var backgroundAlpha:Number = getStyle("backgroundAlpha");
graphics.clear();
cornerRadius = 10;
backgroundColor = 0xFF0000;
backgroundAlpha = 1;
// Background
drawRoundRect(0, 0, unscaledWidth, unscaledHeight, {tl:1, tr:cornerRadius, bl:1, br:1}, backgroundColor, backgroundAlpha);
// Shadow
if (!dropShadow)
dropShadow = new RectangularDropShadow();
dropShadow.distance = 8;
dropShadow.angle = 45;
dropShadow.color = 0;
dropShadow.alpha = 0.4;
dropShadow.tlRadius = 1;
dropShadow.trRadius = cornerRadius;
dropShadow.blRadius = 1;
dropShadow.brRadius = 1;
dropShadow.drawShadow(graphics, 0, 0, unscaledWidth, unscaledHeight);
}
}
}
这应该意味着第一个按钮将是红色的,并且右上角会有一个非常圆的角。相反,我只得到默认按钮。不知道我在那里做错了什么,但如果这不是最好的解决方案,我希望得到一些帮助。谢谢!