| <?xml version="1.0" encoding="utf-8"?> |
| <!-- |
| |
| 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. |
| |
| --> |
| <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" > |
| <fx:Declarations> |
| <!-- Place non-visual elements (e.g., services, value objects) here --> |
| </fx:Declarations> |
| <fx:Script> |
| <![CDATA[ |
| |
| import mx.events.ListEvent; |
| import mx.controls.TextInput; |
| |
| [Bindable] |
| private var contacts1:Object = |
| {label: "top", children: [ |
| {label: "Acme", status: true, phone: "243-333-5555", children: [ |
| {label: "Sales", status: true, phone: "561-256-5555"}, |
| {label: "Support", status: false, phone: "871-256-5555"} |
| ]}, |
| {label: "Ace", status: true, phone: "444-333-5555", children: [ |
| {label: "Sales", status: true, phone: "232-898-5555"}, |
| {label: "Support", status: false, phone: "977-296-5555"}, |
| ]}, |
| {label: "Platinum", status: false, phone: "521-256-5555"} |
| ]} |
| |
| ]]> |
| </fx:Script> |
| <s:Panel width="75%" height="75%" title="MXTreeItemRenderer Example" |
| horizontalCenter="0" verticalCenter="0"> |
| <s:layout><s:VerticalLayout paddingLeft="20"/></s:layout> |
| <!-- default TextInput will be used as itemEditor when editable=true and user clicks in treeItem --> |
| <mx:Tree id="myTree" width="80%" height="75%" |
| labelField="label" |
| showRoot="true" |
| dataProvider="{contacts1}"> |
| <mx:itemRenderer> |
| <fx:Component> |
| <s:MXTreeItemRenderer width="100" height="25"> |
| <s:states> |
| <s:State name="normal" /> |
| <s:State name="hovered" /> |
| <s:State name="selected" /> |
| </s:states> |
| <s:HGroup left="0" right="0" verticalCenter="0"> |
| <s:Rect id="indentationSpacer" width="{treeListData.indent}" height="22" alpha="0"> |
| <s:fill> |
| <s:SolidColor color="0x0000FF" /> |
| </s:fill> |
| </s:Rect> |
| <s:Group id="disclosureGroup"> |
| <s:BitmapImage source="{treeListData.disclosureIcon}" width="16" height="16" visible="{treeListData.hasChildren}" /> |
| </s:Group> |
| <s:BitmapImage source="{treeListData.icon}" width="16" height="16"/> |
| <!-- color is set based on states --> |
| <s:Label text="{data.label}" color.hovered="0xFF0000" color.selected="0x0000FF"/> |
| </s:HGroup> |
| </s:MXTreeItemRenderer> |
| </fx:Component> |
| </mx:itemRenderer> |
| </mx:Tree> |
| <s:CheckBox id="checkBox1" label="Tree Editable" click="myTree.editable=checkBox1.selected"/> |
| </s:Panel> |
| </s:Application> |