Actionscript 3 如何使用操作脚本更改列表组件的背景色
如何使用操作脚本更改列表组件的背景色这是从Actionscript 3 如何使用操作脚本更改列表组件的背景色,actionscript-3,apache-flex,Actionscript 3,Apache Flex,如何使用操作脚本更改列表组件的背景色这是从s:list的contentBackgroundColor样式属性定义的 MXML示例: 从MXML中,设置s:List组件的contentBackgroundColor属性 <?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns
s:list
的contentBackgroundColor
样式属性定义的
MXML示例:
从MXML中,设置s:List
组件的contentBackgroundColor
属性
<?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">
<s:List contentBackgroundColor="0xabcdef">
<s:dataProvider>
<s:ArrayList>
<fx:String>Item 1</fx:String>
<fx:String>Item 2</fx:String>
<fx:String>Item 3</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:List>
</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"
creationComplete="creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function creationCompleteHandler(event:FlexEvent):void
{
list.setStyle("contentBackgroundColor", 0xabcdef);
}
]]>
</fx:Script>
<s:List id="list">
<s:dataProvider>
<s:ArrayList>
<fx:String>Item 1</fx:String>
<fx:String>Item 2</fx:String>
<fx:String>Item 3</fx:String>
</s:ArrayList>
</s:dataProvider>
</s:List>
</s:Application>