@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
话不多说,上代码
1 <?xml version="1.0"?>
2 <!-- Simple example to demonstrate the Spark List component -->
3 <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
4
5 <fx:Script>
6 <![CDATA[
7 import spark.events.IndexChangeEvent;
8
9 //this function is called when the selection is going to change
10 private function selectionChangingHandler(evt:IndexChangeEvent):void {
11 var item:* = list.dataProvider.getItemAt(evt.newIndex);
12 if (item.type != "employee") {
13 evt.preventDefault();
14 }
15 }
16 ]]>
17 </fx:Script>
18
19 <s:Panel title="Spark List Component Example"
20 width="75%" height="75%"
21 horizontalCenter="0" verticalCenter="0">
22 <s:VGroup left="20" right="20" top="20" bottom="20">
23 <s:Label width="330"
24 text="Select a name to see employee's phone number. You should not be able to select the first name."/>
25 <s:List id="list" changing="selectionChangingHandler(event);">
26 <!-- itemRenderer is inline in this sample -->
27 <s:itemRenderer>
28 <fx:Component>
29 <s:ItemRenderer>
30 <s:states>
31 <s:State name="normal" />
32 <s:State name="hovered" />
33 <s:State name="selected" />
34 </s:states>
35 <s:Rect left="0" right="0" top="0" bottom="0">
36 <s:fill>
37 <s:SolidColor color="0x999999" alpha="0" alpha.hovered="0.2"
38 alpha.selected="0.6" />
39 </s:fill>
40 </s:Rect>
41 <s:Label id="nameLabel" text="{data.lastName}, {data.firstName}" top="5" left="5" right="5" />
42 <s:Label y="20" id="phoneLabel" text="{data.phone}" includeIn="selected" top="25" bottom="5" left="5" right="5" />
43 </s:ItemRenderer>
44 </fx:Component>
45 </s:itemRenderer>
46 <s:dataProvider>
47 <s:ArrayList>
48 <fx:Object type="hr" firstName="Ann" lastName="Green" />
49 <fx:Object type="employee" firstName="Tom" lastName="Smith" phone="415-155-1212" />
50 <fx:Object type="employee" firstName="John" lastName="Black" phone="408-344-1234" />
51 <fx:Object type="employee" firstName="Jane" lastName="White" phone="415-235-7878" />
52 <fx:Object type="employee" firstName="Bill" lastName="Jones" phone="415-875-7800" />
53 </s:ArrayList>
54 </s:dataProvider>
55 </s:List>
56 </s:VGroup>
57 </s:Panel>
58
59 </s:Application>
@import url(http://www.blogjava.net/CuteSoft_Client/CuteEditor/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);