| <?xml version="1.0"?> |
| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| |
| --> |
| <!-- Simple example to demonstrate the Spark List component --> |
| <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> |
| |
| <fx:Script> |
| <![CDATA[ |
| import spark.events.IndexChangeEvent; |
| |
| //this function is called when the selection is going to change |
| private function selectionChangingHandler(evt:IndexChangeEvent):void { |
| var item:* = list.dataProvider.getItemAt(evt.newIndex); |
| if (item.type != "employee") { |
| evt.preventDefault(); |
| } |
| } |
| ]]> |
| </fx:Script> |
| |
| <s:Panel title="Spark List Component Example" |
| width="75%" height="75%" |
| horizontalCenter="0" verticalCenter="0"> |
| <s:VGroup left="20" right="20" top="20" bottom="20"> |
| <s:Label width="330" |
| text="Select a name to see employee's phone number. You should not be able to select the first name."/> |
| <s:List id="list" changing="selectionChangingHandler(event);"> |
| <!-- itemRenderer is inline in this sample --> |
| <s:itemRenderer> |
| <fx:Component> |
| <s:ItemRenderer> |
| <s:states> |
| <s:State name="normal" /> |
| <s:State name="hovered" /> |
| <s:State name="selected" /> |
| </s:states> |
| <s:Rect left="0" right="0" top="0" bottom="0"> |
| <s:fill> |
| <s:SolidColor color="0x999999" alpha="0" alpha.hovered="0.2" |
| alpha.selected="0.6" /> |
| </s:fill> |
| </s:Rect> |
| <s:Label id="nameLabel" text="{data.lastName}, {data.firstName}" top="5" left="5" right="5" /> |
| <s:Label y="20" id="phoneLabel" text="{data.phone}" includeIn="selected" top="25" bottom="5" left="5" right="5" /> |
| </s:ItemRenderer> |
| </fx:Component> |
| </s:itemRenderer> |
| <s:dataProvider> |
| <s:ArrayList> |
| <fx:Object type="hr" firstName="Ann" lastName="Green" /> |
| <fx:Object type="employee" firstName="Tom" lastName="Smith" phone="415-155-1212" /> |
| <fx:Object type="employee" firstName="John" lastName="Black" phone="408-344-1234" /> |
| <fx:Object type="employee" firstName="Jane" lastName="White" phone="415-235-7878" /> |
| <fx:Object type="employee" firstName="Bill" lastName="Jones" phone="415-875-7800" /> |
| </s:ArrayList> |
| </s:dataProvider> |
| </s:List> |
| </s:VGroup> |
| </s:Panel> |
| |
| </s:Application> |