1
如何使用動作腳本如何使用動作腳本
如何使用動作腳本如何使用動作腳本
這是從s:List
的contentBackgroundColor
樣式屬性定義爲改變列表組件的backgroundColor改變列表組件的背景色。
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>
的ActionScript示例:
利用ActionScript,設置樣式屬性:setStyle("contentBackgroundColor", 0xabcdef);
<?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>
這也可以通過爲列表創建一個皮膚類來完成。