代码:

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"   
  3.                xmlns:s="library://ns.adobe.com/flex/spark"   
  4.                xmlns:mx="library://ns.adobe.com/flex/mx"   
  5.                minWidth="955" minHeight="600" xmlns:logic="contr.*"> 
  6.     <fx:Declarations> 
  7.         <!-- 将非可视元素(例如服务、值对象)放在此处 --> 
  8.         <fx:XMLList id="treeData"> 
  9.             <node label="选择数据集"> 
  10.                 <node label="hsql"> 
  11.                     <node label="tabels"> 
  12.                           <node label="订单" head="p_w_picpaths/install.jpg"/> 
  13.                           <node label="订单明细" head="p_w_picpaths/install.jpg"/> 
  14.                           <node label="雇员" head="p_w_picpaths/install.jpg"/> 
  15.                     </node>   
  16.                 </node> 
  17.                 <node label="mysql"> 
  18.                     <node label="tabels"> 
  19.                           <node label="demo_salesday" head="p_w_picpaths/install.jpg"/> 
  20.                           <node label="Personal" head="p_w_picpaths/install.jpg"/> 
  21.                     </node>   
  22.                 </node> 
  23.             </node> 
  24.         </fx:XMLList> 
  25.     </fx:Declarations> 
  26.     <mx:VBox backgroundColor="#CCCCCC" width="100%" height="100%" verticalAlign="middle" horizontalAlign="center"> 
  27.         <mx:Tree dataProvider="{treeData}" width="200" height="200" labelField="@label"  depthColors="[#CCCCCC,#f60f0f,#1c47e8,#31eb18]"/> 
  28.     </mx:VBox> 
  29. </s:Application> 

效果:

flex 学习笔记 tree的各个子级的颜色_flex