简体   繁体   中英

How to set backgroundGround color in Rect spark

<s:Group id="ellipse2" x="-50" y="-50" width="100" height="100">
                <s:Rect width="100" height="100" x="0" y="0"> 
                    <s:stroke> 
                        <s:LinearGradientStroke weight="1"> 
                            <s:GradientEntry color="0xFF0000"/> 
                        </s:LinearGradientStroke> 
                    </s:stroke> 
                </s:Rect>
                <s:Label id="label" text="Hello World" width="100%" height="100%" textAlign="center" verticalAlign="middle" />
            </s:Group>

I've tried to set the backgroundColor from the styles, but that doesn't worked, how can I set the backgroundColor, not the gradient?

As @Reboog711 stated: the Spark primitive graphics components like Rect do not support styles. They are intended to be light weight objects, and thus don't have all the capabilities that other Flex components do.

It sounds like you want to set the fill property of the Rect :

<s:Rect width="100" height="100">
    <s:fill>
        <s:SolidColor color="#ff0000"/>
    </s:fill>
</s:Rect>

The fill can be a SolidColor as above, or you can use use one of the other classes that implements the IFill interface: BitmapFill , LinearGradient , or RadialGradient .

The "stroke" tag is used for giving the color to a "line" not for an area/region. To fill background of area/region, you should use this:

<s:Rect width="100" height="100">
 <s:fill>
  <s:SolidColor color="yourColorCode" />
 </s:fill>
</s:Rect>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM