如何在FLEX中更改DropDownList的BackGround颜色?

Fel*_*ida 2 apache-flex mxml flex4 flex4.5

这就是我到目前为止所做的.

       <!-- fill -->
        <!--- Defines the appearance of drop-down list's background fill. -->
        <s:Rect id="background" left="1" right="1" top="1" bottom="1" >
            <s:fill>
            <!---  
                The color of the drop down's background fill.
                The default color is 0xFFFFFF.
            -->
                <s:SolidColor id="bgFill" color="#DB9E36"/>
            </s:fill>
        </s:Rect>
Run Code Online (Sandbox Code Playgroud)

如果你仔细观察,你会发现我已经改变了bgFill颜色的默认值.但是,当我运行我的应用程序时,下拉列表的背景颜色仍然是默认的白色.

我在这里做错了吗?

提前致谢.

Jef*_*ser 5

简单的方法是使用contentBackgroundColor样式.像这样的东西:

<s:DropDownList contentBackgroundColor="0xDB9E36" >
    <s:dataProvider>
        <mx:ArrayCollection>
            <fx:String>Flash</fx:String> 
            <fx:String>Director</fx:String> 
            <fx:String>Dreamweaver</fx:String> 
            <fx:String>ColdFusion</fx:String> 
            <fx:String>Flash</fx:String> 
            <fx:String>Director</fx:String> 
            <fx:String>Dreamweaver</fx:String> 
            <fx:String>ColdFusion</fx:String> 
            <fx:String>Flash</fx:String> 
            <fx:String>Director</fx:String> 
            <fx:String>Dreamweaver</fx:String> 
            <fx:String>ColdFusion</fx:String> 
        </mx:ArrayCollection>           
    </s:dataProvider>
</s:DropDownList>
Run Code Online (Sandbox Code Playgroud)

更多细节..

创建自定义皮肤时; 有一个名为contentFill的属性列表; 定义如下:

 static private const contentFill:Array = ["bgFill"];
Run Code Online (Sandbox Code Playgroud)

您会注意到这里列出的值是bgFill; 您尝试更改颜色的相同背景..可以使用contentItem属性公开检索它:

override public function get contentItems():Array {return contentFill};
Run Code Online (Sandbox Code Playgroud)

SparkSkin类[默认情况下所有MXML外观都扩展]在updateDisplayList中访问此值.contentItems数组中的每个属性都使用contentBackgroundColor指定它的背景颜色,并使用contentBackgroundAlpha指定它的alpha.

在MXML中明确定义值然后[可能]在ActionScript中覆盖,这有点误导.