2011-10-18 4 views
0

フレックスで3つの異なる色を持つ長方形を作りたいと思っています。私は塗りつぶしや勾配のようなスパーク成分を使いましたが、このように3つの色を並べることはできませんでした。フレックスでオブジェクトの異なるグラデーションの色を描く

黒赤色 - 黒色比0.2 0.8 0.2。私は2つの色だけを稼働させることができますが、この比率ではありません。また、私は矩形ではなく、グラデーションで単色をしたい。

<s:Rect id="rectangle1" height="100" width="300"> 
    <s:fill> 
     <s:LinearGradient> 
      <s:GradientEntry color="black" ratio="0.5" alpha="1"/> 
      <s:GradientEntry color="red" ratio="0.5" alpha="1"/> 
    </s:LinearGradient> 
    </s:fill> 
</s:Rect> 

答えて

1

3矩形が欲しいと言っていませんか?グラデーションが必要ですが、ソリッドカラー(グラデーションなし)が必要です。

このような意味ですか?

3 Rectangles

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       minWidth="955" 
       minHeight="600"> 

    <s:Rect id="rectangle1" 
      height="15" 
      width="300"> 
     <s:fill> 
      <s:SolidColor color="0x0" /> 
     </s:fill> 
    </s:Rect> 

    <s:Rect id="rectangle2" 
      top="15" 
      height="70" 
      width="300"> 
     <s:fill> 
      <s:SolidColor color="0xff0000" /> 
     </s:fill> 
    </s:Rect> 

    <s:Rect id="rectangle3" 
      top="85" 
      height="15" 
      width="300"> 
     <s:fill> 
      <s:SolidColor color="0x0" /> 
     </s:fill> 
    </s:Rect> 

</s:Application> 

そうでなければ、この種のこのようなあなたの目標を達成することができます

<?xml version="1.0" encoding="utf-8"?> 
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
       xmlns:s="library://ns.adobe.com/flex/spark" 
       xmlns:mx="library://ns.adobe.com/flex/mx" 
       minWidth="955" 
       minHeight="600"> 

    <s:Rect id="rectangle1" 
      height="100" 
      width="300"> 
     <s:fill> 
      <s:LinearGradient rotation="90"> 
       <s:GradientEntry color="0x0" ratio="0" /> 
       <s:GradientEntry color="0x0" ratio=".2" /> 
       <s:GradientEntry color="0xff0000" ratio=".2" /> 
       <s:GradientEntry color="0xff0000" ratio=".8" /> 
       <s:GradientEntry color="0x0" ratio=".8" /> 
      </s:LinearGradient> 
     </s:fill> 
    </s:Rect> 

</s:Application> 
+0

これは、それが必要なものを正確に感謝です!私は比率を設定する混乱してしまった。 –

関連する問題