鸿 网 互 联 www.68idc.cn

flex Tree 相本 json格式数据

来源:互联网 作者:佚名 时间:2015-08-10 06:55
flex Tree 相册 json 格式 数据 引用 ?xml version="1.0" encoding="utf-8"? !-- http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/ -- mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" lay
flex Tree 相册 json格式数据
引用

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/04/04/creating-a-simple-image-gallery-with-the-flex-tree-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white"
initialize="initTree()"
viewSourceURL="srcview/index.html">

<mx:Script>
<![CDATA[
import mx.events.ListEvent;
import mx.controls.Alert;
[Bindable] public var switchObj:Object = new Object();
private function initTree():void
{
switchObj = [
{
label:'All',
children:
[
{label:"Illustrator",src:'resource/images/ai_appicon.jpg'},
{label:"secondChild",src:'resource/images/cf_appicon.jpg'}
]
} ,
{
label:'RIA',
children:
[
{label:"ColdFusion",src:'resource/images/cf_appicon.jpg'},
{label:"Dreamweaver",src:"resource/images/dw_appicon.jpg"},
{label:"Flash",src:"resource/images/fl_appicon.jpg"}
]
} ,
{
label:'Server',
children:
[
{label:"ColdFusion",src:'resource/images/cf_appicon.jpg'},
{label:"Flex",src:"resource/images/fx_appicon.jpg"}
]
}
];
}


private function tree_itemClick(evt:ListEvent):void {
var t:Tree = evt.currentTarget as Tree;
var dataObj:Object = evt.itemRenderer.data;

if (dataObj.hasOwnProperty("src")) {
swfLoader.source = dataObj.src;
} else if (t.dataDescriptor.isBranch(t.selectedItem)) {
swfLoader.source = null;
panel.status = "";
}
}
// tree中配置属性执行函数labelFunction="tree_labelFunc"
private function tree_labelFunc(item:Object):String {

var suffix:String = "";
if (tree.dataDescriptor.isBranch(item)) {
suffix = " (" + item.children.length + ")";

}
return item.label + suffix;
}

private function swfLoader_complete(evt:Event):void {
panel.status = (swfLoader.bytesTotal/1024).toFixed(2) + 'KB';
}

]]>
</mx:Script>

<mx:XML id="dp" source="data/dp.xml" />

<mx:HDividedBox width="100%" height="100%">
<mx:Panel width="200" height="100%">
<mx:Tree id="tree"
dataProvider="{switchObj}"
labelField="label"
labelFunction="tree_labelFunc"
showRoot="true"
width="100%"
height="100%"
itemClick="tree_itemClick(event);" />
</mx:Panel>
<mx:Panel id="panel"
  width="100%"
  height="100%"
  backgroundColor="white">
<mx:SWFLoader id="swfLoader"
  scaleContent="true"
  width="100%"
  height="100%"
  complete="swfLoader_complete(event);" />
<mx:ControlBar>
<mx:LinkButton label="{swfLoader.source.toString()}" />
</mx:ControlBar>
</mx:Panel>
</mx:HDividedBox>

</mx:Application>

网友评论
<