flex 左侧树形菜单,打击左侧菜单 右侧添加一个NavigatorContent

来源:互联网 发布:手机如何网络翻墙 编辑:程序博客网 时间:2024/06/07 13:59
<?xml version="1.0" encoding="utf-8"?>
<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" 
  xmlns:view="com.talent.business.login.mode.*" 
  xmlns:flexlib="http://code.google.com/p/flexlib/" 
  creationComplete="init(event)"
  fontFamily="宋体" fontSize="15"
  width="100%" height="100%"
  minWidth="955" minHeight="600">
<fx:Style source="com/talent/css/style.css"/>
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
mx|Grid{

}
mx|Tree{
folderClosedIcon:ClassReference(null);
folderOpenIcon:ClassReference(null);
defaultLeafIcon:ClassReference(null);
disclosureOpenIcon:Embed(source='assets/images/text/11.gif');
disclosureClosedIcon:Embed(source='assets/images/text/12.gif');



/*backgroundAlpha: 0.9;*/
/*backgroundColor: #ffcc00;*//*//背景颜色*/
alternatingItemColors: #FFFFFF,#EEEEEE;
depthColors:  #EEEEEE,#FFFFFF, #EEEEEE ,#FFFFFF;
useRollOver: true;/*滚动条*/
/*rollOverColor: #99cc00;*//*鼠标移动上背景显示颜色*/
textRollOverColor: #cc0000;/*鼠标移动上字体显示红色*/
/*borderStyle: solid;*/
/*borderThickness: 2;*/
/*borderColor: #cc0000;*/
/*selectionColor: #0033ff;*/
/*color: #cccccc;*//*字体颜色*/
textSelectedColor: #198DDA;/*文本选中的字体颜色*/
textIndent: 20;/*文本与最左侧的距离*/
indentation: 21;
openDuration: 285;
selectionDuration: 517;
/*fontFamily: Arial Black;*/
/*fontSize: 15;*//*字体大小*/
/*fontWeight: bold;*//*字体粗细*/
/*fontStyle: italic;*//*字体*/
/*textDecoration: underline;*//*文本下划线*/
/*cornerRadius: 8;*/
}
</fx:Style>


<fx:Declarations>
<fx:XML id="treeXML">
<root label="监控点">
<node label="设置">
<node label="供应商管理" source="com/talent/business/sz/model/gysManager" code="DMMSUPPLIER"/>
<node label="产品类别" source="com/talent/business/sz/model/gysManager" code="DMMMERCHANDISE_LB"/>
<node label="产品管理" source="com/talent/business/sz/model/gysManager" code="DMMMERCHANDISE"/>
<node label="流程管理" source="com/talent/business/sz/model/lcglManager" code=""/>
<node label="修改密码" source="com/talent/business/sz/model/xgmmManager" code=""/>
</node>
<node label="采购">
<node label="采购申请" source="com/talent/business/xians/model/cgsqManager"/>
<node label="进货单" source="com/talent/business/xians/model/jhdManager"/>
<node label="退货单" source="com/talent/business/xians/model/thdManager"/>
</node>
s </root>
</fx:XML>
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.inpor.business.login.proxy.RightProxy;
import com.inpor.business.login.vo.LoginBeanVo;

import mx.collections.XMLListCollection;
import mx.containers.Canvas;
import mx.controls.Label;
import mx.events.FlexEvent;

import spark.modules.ModuleLoader;
private var rightProxy:RightProxy=new RightProxy();
private var loginbean:LoginBeanVo;
protected function add_clickHandler(event:Event):void 
{  
var selectedNode:XML =tree.selectedItem as XML;

if(selectedNode.hasComplexContent()){                  //代表有子节点

}else     //没有子节点
{
var node:XML = tree.selectedItem as XML;
var canvas:Canvas = new Canvas(); 
var la:String=node.@code;
canvas.label = node.@label; 
var source:String=node.@source;
var label:Label = new Label(); 
var first:ModuleLoader=new ModuleLoader();
first=new ModuleLoader();
canvas.addElement(first);
canvas.addChild(label); // label add to canvas
tabNavigator.addChild(canvas); // canvas add to tabNavigator 
tabNavigator.selectedChild=canvas;
loadModule(first,source+".swf?la="+la);
//Alert.show("111111111111111111111111"+source);
}


public function loadModule(mloader:ModuleLoader, murl:String):void {

mloader.url = murl;  //在模块的url被修改之后,会自动激发模块加载
mloader.loadModule(); //如果模块已经设置了url,则直接将模块加载

}
import mx.controls.Alert;
protected function openAll():void{
//tree.expandChildrenOf(tree.selectedItem,true);
tree.openItems = treeXML..node;

//tree.selectedItem = treeXML;
for(var i:int = 0;i<tree.dataProvider.length;i++)

var xml:XML = (tree.dataProvider as XMLListCollection).getItemAt(i) as XML
var xmlIst:XMLList= xml.children();
if(tree.dataProvider[i].@Node == "")
{
tree.selectedIndex = i;
break;

}

}
protected function closeAll():void{
tree.openItems=[];
//tree.selectedItem = treeXML;
}




]]>
</fx:Script>
<s:VGroup x="0" y="0" height="100%"  width="100%" visible.init="false" visible.logged="true">


<s:HGroup x="0" y="0" width="100%" height="100%">
<s:Panel x="10" y="10" width="292" height="100%" title="进销存" fontSize="15" textAlign="left" chromeColor="#E3F6FC">
<s:Button x="0" y="0" label="展开所有" id="openTree"  click="openAll()"/>
<s:Button x="80" y="0" label="关闭所有" id="closeTree" click="closeAll()"/>
<s:BorderContainer x="0" y="19" width="100%" height="100%" click="click_no()">
<mx:Tree id="tree" width="100%" height="100%" dataProvider="{treeXML}" labelField="@label" showRoot="false" y="0" itemClick="add_clickHandler(event)"/>
</s:BorderContainer>
</s:Panel>
<s:Group x="226" y="0" width="100%" height="100%">
<flexlib:SuperTabNavigator id="tabNavigator" width="100%" height="100%"  >
</flexlib:SuperTabNavigator>
</s:Group>
</s:HGroup>

</s:VGroup>
</s:Application>
0 0
原创粉丝点击