浏览 1683 次
锁定老帖子 主题:Flex RoundCorner
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2008-09-12
<?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"> <mx:Script> <![CDATA[ import mx.utils.GraphicsUtil; import flash.display.Graphics; [Bindable] public var gradientColors:Array; [Bindable] public var gradientAlphas:Array; [Bindable] public var gradientRatios:Array; [Bindable] public var gradientAngle:int; [Bindable] public var innerRadius:Number; [Bindable] public var roundCornerFlag : Boolean = true; [Bindable] public var topLeftRadius : Number = 0; [Bindable] public var topRightRadius : Number = 0; [Bindable] public var bottomLeftRadius : Number = 0; [Bindable] public var bottomRightRadius : Number = 0; override protected function updateDisplayList(unscaledWidth : Number, unscaledHeight : Number) : void { super.updateDisplayList(unscaledWidth, unscaledHeight); var fillType:String = GradientType.LINEAR; var colors:Array = gradientColors; var alphas:Array = gradientAlphas; var ratios:Array = gradientRatios; var matrix:Matrix = new Matrix(); matrix.createGradientBox(unscaledWidth, unscaledHeight, (gradientAngle * Math.PI/180)); var spreadMethod:String = SpreadMethod.PAD; graphics.clear(); graphics.beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod); if(roundCornerFlag) { drawAllRoundCorner(graphics, unscaledWidth, unscaledHeight); } else { customizeRoundCorner(graphics, unscaledWidth, unscaledHeight); } graphics.endFill(); } public function drawAllRoundCorner(graphics : Graphics, unscaledWidth : Number, unscaledHeight : Number) : void { if(isNaN(innerRadius)) { graphics.drawRect(1, 1, unscaledWidth - 1, unscaledHeight - 1); } else { graphics.drawRoundRect(1, 1, unscaledWidth - 2, unscaledHeight - 2, innerRadius); } } public function customizeRoundCorner(graphics : Graphics, unscaledWidth : Number, unscaledHeight : Number) : void { GraphicsUtil.drawRoundRectComplex(graphics, 1, 1, unscaledWidth - 2, unscaledHeight - 2, topLeftRadius,topRightRadius, bottomLeftRadius, bottomRightRadius); } ]]> </mx:Script> </mx:VBox> 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |