我过去曾使用程序化皮肤做到这一点。您需要创建自己的 ProgressBarSkin 和 ProgressBarMaskSkin 版本以及可选的 ProgressBarTrackSkin。在您的 ProgressBarSkin 中,您可以像这样覆盖 updateDisplayList 方法:
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
graphics.clear();
var fullWidth:int = w;
if (parent != null && (parent as UIComponent).mask != null)
fullWidth = (parent as UIComponent).mask.width;
var matrix:Matrix = new Matrix();
matrix.createGradientBox(fullWidth, h);
var colors:Array = [0xd00000, 0xf0d000, 0x00ff00];
this.graphics.lineStyle();
this.graphics.beginGradientFill(GradientType.LINEAR, colors, [1,1,1], [0,128,255], matrix);
this.graphics.drawRoundRect(2, 2, w - 4, h - 4, h - 4);
}
在你的 ProgressBarMaskSkin 中这样做:
override protected function updateDisplayList(w:Number, h:Number):void {
super.updateDisplayList(w, h);
graphics.clear();
this.drawRoundRect(2, 2, w - 4, h - 4, (h - 4) / 2, 0xffffff, 1);
}
然后你将你的皮肤类分配给你的进度条,你就设置好了。希望对您有所帮助。