Flex menubar导航栏加载moudels
2013-08-29
展开全部
<!-- 系统菜单 -->
<mx:MenuBar id="menu" right="10" labelField="modName"
itemClick="loadModule(event)"
/>
<!-- 模块组件 -->
<s:ModuleLoader id="modLoader" top="30" bottom="0" left="0" right="0"
ready="onModuleLoaded()"/>
/**
* 单击菜单项,加载模块
*/
protected function loadModule(event:MenuEvent):void
{
object=null;
pickHangObject = null;
var modId:int = event.item.modId;
if(modId == -100) {
return logout();
}
var modType:int = event.item.modType;
var modUrl:String = event.item.modUrl;
// 如果是模块,则用ModuleLoader加载
if(modType == 1 && currentUrl != modUrl){
loading.visible = true;
var mod:Module = Module(modLoader.child);
// 如果模块有定义挂起函数,则使旧模块的挂起,用以切换新的模块
if(mod && mod.hasOwnProperty("suspend")) {
mod["suspend"].call();
}
modLoader.unloadModule();
modLoader.loadModule(modUrl);
currentUrl = modUrl;
}
// 如果是组件,则用PopUpManager加载
else if(modType == 2) {
var c:Class = getDefinitionByName(modUrl) as Class;
var x:IFlexDisplayObject = PopUpManager.createPopUp(this, c);
PopUpManager.centerPopUp(x);
}
}
<mx:MenuBar id="menu" right="10" labelField="modName"
itemClick="loadModule(event)"
/>
<!-- 模块组件 -->
<s:ModuleLoader id="modLoader" top="30" bottom="0" left="0" right="0"
ready="onModuleLoaded()"/>
/**
* 单击菜单项,加载模块
*/
protected function loadModule(event:MenuEvent):void
{
object=null;
pickHangObject = null;
var modId:int = event.item.modId;
if(modId == -100) {
return logout();
}
var modType:int = event.item.modType;
var modUrl:String = event.item.modUrl;
// 如果是模块,则用ModuleLoader加载
if(modType == 1 && currentUrl != modUrl){
loading.visible = true;
var mod:Module = Module(modLoader.child);
// 如果模块有定义挂起函数,则使旧模块的挂起,用以切换新的模块
if(mod && mod.hasOwnProperty("suspend")) {
mod["suspend"].call();
}
modLoader.unloadModule();
modLoader.loadModule(modUrl);
currentUrl = modUrl;
}
// 如果是组件,则用PopUpManager加载
else if(modType == 2) {
var c:Class = getDefinitionByName(modUrl) as Class;
var x:IFlexDisplayObject = PopUpManager.createPopUp(this, c);
PopUpManager.centerPopUp(x);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询