简体   繁体   English

如何在Rect spark中设置backgroundGround颜色

[英]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? 我试图从样式中设置backgroundColor,但这不起作用,我如何设置backgroundColor,而不是渐变?

As @Reboog711 stated: the Spark primitive graphics components like Rect do not support styles. 正如@ Reboog711所说:像Rect这样的Spark原始图形组件不支持样式。 They are intended to be light weight objects, and thus don't have all the capabilities that other Flex components do. 它们旨在成为轻量级对象,因此不具备其他Flex组件所具有的所有功能。

It sounds like you want to set the fill property of the Rect : 听起来你想设置Rectfill属性:

<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 . fill可以是上面的SolidColor ,也可以使用实现IFill接口的其他类之一: BitmapFillLinearGradientRadialGradient

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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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