zoukankan      html  css  js  c++  java
  • [Flex] 组件Tree系列 —— 将数组作为dataProvider

    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>
  • 相关阅读:
    糊涂的教授
    有趣的英语角
    聚会
    新年礼物
    三核苷酸
    数字编码
    【同行说技术】iOS程序员从小白到大神必读资料汇总
    【同行说技术】Android图片处理技术资料汇总(一)
    【同行说技术】swift最全学习资料汇集(一)
    【同行说技术】iOS程序员从小白到大神必读资料汇总(一)
  • 原文地址:https://www.cnblogs.com/frost-yen/p/4308820.html
Copyright © 2011-2022 走看看