2009-06-08 22 views
0

我想知道如何在flex中應用漸變和轉角半徑。如何應用漸變是flex?而拐角半徑

css是唯一的方法嗎?我的意思是我想要使用更多的flex屬性來實現這一點

有人可以給它一個樣本類或代碼嗎?

感謝

回答

0

首先,如你所提到的,這些屬性可以通過CSS定製(header-colorsbackground-gradient-colorshighlight-alphas等)

其次,您可以使用Flash繪圖API來創建自己的形狀定製(或擴展)組件,但它更棘手的任務:

package test 
{ 
import mx.core.UIComponent; 
import flash.display.Graphics; 
import flash.display.GradientType; 

public class DrawingTest extends UIComponent 
{ 
    public function DrawingTest() 
    { 
     super(); 
    } 

    override protected function updateDisplayList (unscaledWidth:Number, unscaledHeight:Number):void 
    { 
     // you'll want to track the actual changes and redraw only in case if width, height or some other 
     // significant property changes 
     trace(unscaledWidth, unscaledHeight); 
     var g:Graphics = graphics; 
     // it's likely you want to make roundRadius and gradient parameters as styles of the component 
     // or at least it's parameters. 
     var roundRadius:Number = 30; 
     g.clear(); 
     g.beginGradientFill(GradientType.LINEAR, [0x0, 0xFFFFFF], [0.5, 0.7], [0, 255]); 
     g.drawRoundRect(0, 0, unscaledWidth, unscaledHeight, roundRadius, roundRadius); 
     g.endFill(); 
    } 

} 
} 

用法(添加xmlns:test="test.*"到頂級組件屬性)

<test:DrawingTest width="250" height="400" /> 

這是很好的看一看Graphics class documentation進一步信息: