mxml:

<?xml version="1.0" encoding="utf-8"?>

<!--功能描述:将数组作为dataProvider-->

<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" minWidth="955" minHeight="600"> <fx:Script>
<![CDATA[
protected function tree_labelFunction(item:Object):String
{
var num:String = "";
if (tree.dataDescriptor.hasChildren(item)) {
num = " (" + item.children.length + ")";
}
return item.label + num;
}
]]>
</fx:Script> <fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:Array id="data">
<fx:Object label="周星驰">
<fx:children>
<fx:Object label="1988">
<fx:children>
<fx:Object label="《霹雳先锋》香港票房8916612" />
<fx:Object label="《捕风汉子》香港票房3149395" />
<fx:Object label="《最佳女婿》香港票房5807710" />
</fx:children>
</fx:Object>
<fx:Object label="1989">
<fx:children>
<fx:Object label="《龙在天涯》香港票房6809853 " />
<fx:Object label="《义胆群英》香港票房7913329" />
<fx:Object label="《流氓差婆》香港票房5624622 " />
<fx:Object label="《风雨同路》香港票房9335299 " /> </fx:children>
</fx:Object>
</fx:children>
</fx:Object>
<fx:Object label="李连杰">
<fx:children>
<fx:Object label="1992">
<fx:children>
<fx:Object label="笑傲江湖之东方不败(1992)" />
<fx:Object label="黄飞鸿之二男儿当自强(1992)" />
<fx:Object label="黄飞鸿之三狮王争霸(1992)" />
</fx:children>
</fx:Object>
<fx:Object label="1993">
<fx:children>
<fx:Object label="方世玉Ⅱ万夫莫敌(1993) " />
<fx:Object label="倚天屠龙记之魔教教主(1993)" />
<fx:Object label="黄飞鸿之铁鸡斗蜈蚣(1993) " />
<fx:Object label="太极张三丰(1993) " /> </fx:children>
</fx:Object>
<fx:Object label="1993">
<fx:children>
<fx:Object label="新少林五祖(1994) " />
<fx:Object label="精武英雄(1994)" />
<fx:Object label="中南海保镖(1994) " />
<fx:Object label="给爸爸的信(1995) " />
</fx:children>
</fx:Object>
</fx:children>
</fx:Object>
</fx:Array>
</fx:Declarations> <mx:Tree id="tree" dataProvider="{data}" labelField="label" width="320" labelFunction="tree_labelFunction"/>
</s:Application>

[Flex] 组件Tree系列 —— 将数组作为dataProvider的更多相关文章

  1. [Flex] 组件Tree系列 —— 打开和关闭节点

    mxm: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:打开和关闭节点--> < ...

  2. [Flex] 组件Tree系列 —— 运用variableRowHeight和wordWrap设置可变行高

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:运用variableRowHeig ...

  3. [Flex] 组件Tree系列 —— 作为PopUpButton的弹出菜单

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:Tree作为PopUpButton ...

  4. [Flex] 组件Tree系列 —— 支持元素的拖放排序

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:支持元素拖放排序--> &l ...

  5. [Flex] 组件Tree系列 —— 利用firstVisibleItem属性,设置或取得第一个显示节点

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述: 利用firstVisibleIt ...

  6. [Flex] 组件Tree系列 —— 运用LabelFunction hasChildren getChildren设置Tree包含节点个数

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:运用LabelFunction h ...

  7. [Flex] 组件Tree系列 —— 运用openItems获取打开节点

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:运用openItems获取打开节点 ...

  8. [Flex] 组件Tree系列 —— 支持CheckBox组件

    主程序mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:支持CheckBox--&g ...

  9. [Flex] 组件Tree系列 —— 阻止用户点击选中Tree中分支节点

    mxml: <?xml version="1.0" encoding="utf-8"?> <!--功能描述:阻止用户点击选中Tree中分支节点 ...

随机推荐

  1. 压力测试工具--Siege

    Siege是一款开源的压力测试工具,设计用于评估WEB应用在压力下的承受能力.可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行.s ...

  2. JS中的函数声明和函数表达式的区别,即function(){}和var function(){},以及变量提升、作用域和作用域链

    一.前言 Uncaught TypeError: ... is not a function function max(){}表示函数声明,可以放在代码的任何位置,也可以在任何地方成功调用: var ...

  3. 746. Min Cost Climbing Stairs 最不费力的加权爬楼梯

    [抄题]: On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once yo ...

  4. word 标题序号

    设置标题的序号. 1>设置二级标题的序号  步骤一: 步骤二: 步骤三: 步骤四: 2>设置三级标题的序号 程序员的基础教程:菜鸟程序员

  5. 隐藏在default construct后面的是什么

    C++新手很容易陷入两个认识上的误区: 1.任何类如果不显示的定义一个构造函数那么编译器就会构造出一个默认构造函数. 2.默认构造函数负责类的所有数据成员的初始化,显然不是这样的. 为什么不是这样的, ...

  6. 修改字段名change

    ALTER TABLE tc_activity_miaosha_item CHANGE `batch_id` `movie_batch_id` INT () NOT NULL DEFAULT ' CO ...

  7. [Training Video - 4] [Groovy] Optional parameter in groovy

    Employee.log=log Employee e1 = new Employee() log.info e1.add(1,2,3,4) // optional parameters in gro ...

  8. C#中把任意类型的泛型集合转换成SQLXML数据格式的小例子

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  9. 03 Complementing a Strand of DNA

    Problem In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'. The r ...

  10. [GO]方法的继承

    package main import "fmt" type Person struct { name string sex byte age int } func (tmp Pe ...