春天到了,我也来种种树!
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()" fontSize="14">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import com.test.TreeVO;
public var open:Object = new Object();
public var refreshData:Boolean = true;
//原始测试数据
private var datas:Array = [
{name:'相册',dir_id:1,parent_id:0,del:0},
{name:'我的照片',dir_id:2,parent_id:1,del:0},
{name:'朋友的照片',dir_id:3,parent_id:1,del:0},
{name:'我的文件',dir_id:4,parent_id:0,del:0},
{name:'工具软件',dir_id:5,parent_id:4,del:0},
{name:'系统软件',dir_id:6,parent_id:4,del:0},
{name:'影音娱乐',dir_id:7,parent_id:0,del:0}
];
[Bindable]
private var treeSource:ArrayCollection = new ArrayCollection(); //tree Data
private function chg():void{
Alert.show(menu.selectedItem.parent_id.toString(),"系统消息");
}
private function init():void{
if(0 != datas.length){
for each (var node:TreeVO in datas){
if(0 == node.parent_id){
var treeNode:Object = new Object();
trace("node:" + node.name);
treeNode.name = node.name;
treeNode.dir_id = node.dir_id;
treeNode.parent_id = node.parent_id;
var sub_arr:ArrayCollection = new ArrayCollection();
for each (var subnode:TreeVO in datas){
if(subnode.parent_id == node.dir_id){
trace("subNode:" + subnode.name);
sub_arr.addItem(subnode);
}
}
if(0 != sub_arr.length){
treeNode.children = new Array();
treeNode.children = sub_arr;
}
treeSource.addItem(treeNode);
}
}
}
}
private function render():void{
if(refreshData){
// Refresh all rows on next update.
menu.invalidateList();
refreshData = false;
menu.openItems = open;
// Validate and update the properties and layout
// of this object and redraw it, if necessary.
menu.validateNow();
}
}
]]>
</mx:Script>
<mx:Tree render="render()" showRoot="false" change="chg()" id="menu" dataProvider="{treeSource}" labelField="name" width="300" height="100%">
</mx:Tree>
</mx:Application>
package com.test
{
public class TreeVO
{
public function TreeVO()
{
}
private var _name:String;
private var _dir_id:int;
private var _parent_id:int;
public function set name(name:String):void{
this._name = name;
}
public function get name():String{
return this._name;
}
public function set dir_id(dir_id:int):void{
this._dir_id = dir_id;
}
public function get dir_id():int{
return this._dir_id;
}
public function set parent_id(parent_id:int):void{
this._parent_id = parent_id;
}
public function get parent_id():int{
return this._parent_id;
}
}
}
- 大小: 13.3 KB
分享到:
相关推荐
flex json转无限树形加单选框并获得选中子项 自动展开
flex JSON 转无限树形加单选框并获得选中子项、
flex3 json官方包 flex3 json官方包
NOTHING Flex使用json和xml数据交互
Flex 树形 ComboBox组件,Flex 树形 ComboBox组件,Flex 树形 ComboBox组件
flex 可拖动的树形自定义控件,从左选项框拖动到右选项框
flex解析json的swc包(entity-flex-v1-02)及例子
flex 解析json的包, 用于前台显示,方便操作!
Flex与JSON及XML的互操作,一篇Info的文章。
JSwoof是一个当前Flex解释Json最快的工具,是Flex下的包,即当你做Flex+Java的开时,你可以利用JSwoof这个工具包很好地在Java Json格式的数据与Flex中的对象相互转换。 比如JSwoof中的JParser.decode()方法: ...
flex json,flex与java进行数据交互是json的相互转化
用于Flex开发所用的json包,直接解压到工作目录即可
Adobe官方提供的Flex解析Json的ActionScript包
FlexViewer 树形结构带checkbox,勾选checkbox节点调用地图加载点标注
Flex 解析Json 引入:import json JParser; var uinfo:Object new Object ; uinfo fun "checkMeetingUser"; uinfo uid "12"; uinfo meetId "1"; var strJson:...
flex复选树形下拉框,在ReportListPage.mxml里面有应用及树数据的加载
Flex的JSON解析包,使用的时候记得加引用 import com.adobe.serialization.json.*;
flex json 包 ,用于将list array 等直接转换成json格式
Flex3中用到的工具类包,含有json类,在flex3中用到json的话,这个包很有用哦,src为源码,lib中为swc文件