Flex RoundCorner

3583 단어 xmlFlexFlash
VBox 원 각 설정 에 관 한 자 료 를 많이 보고 하루 동안 연 구 했 더 니 얻 은 것 이 있 습 니 다. 먼저 보 내 드 리 겠 습 니 다.

<?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>

좋은 웹페이지 즐겨찾기