如题,就是这个setState()方法很莫名其妙的在那里,可是又不知道谁会调用它,来设置模块载入。而且Flex  API 上也查不到!啊啊啊啊!莫名其妙!<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication 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:modules="org.bishow.modules.*"
   showStatusBar="false" initialize="init()" 
   creationComplete="loadComplete()" applicationComplete="applicationCompleteHandler(event)">
<fx:Declarations>
<!--加载xml文件-->
<s:HTTPService id="initConfig" method="POST" resultFormat="e4x" showBusyCursor="true" result="initConfig_resultHandler(event)" fault="initConfig_faultHandler(event)">
</s:HTTPService>
</fx:Declarations>
<!--
系统模块区分: 版本 1
1、城市资源        areaResource
2、卫生资源        hygieneResource
3、综合医院        hospitalResource
4、社区服务        communityResource
5、监控指标        dataAnalysis
6、综合展示        chartCenter
7、远程会议        whiteboard
8、退出            out

将城市资源、卫生资源合并在一页,resource

版本 2

医疗保障 medicalSecurity
综合管理 ChartCenter
药品管理 DrugManagement
公共卫生 PublicHealthDataAnalysis
医疗服务 MedicalServiceDataAnalysis
远程会议 whiteboard
区域资源 Resource
综合医院 hospitalResource
社区服务 communityResource
乡镇医院 townshipResource
卫生监督 supervisionResource
疾控中心 supervisionResource -->
<fx:Script>
<![CDATA[
import com.greensock.TweenMax;
import com.greensock.easing.Cubic;
import mx.controls.Alert;
import mx.core.UIComponent;
import mx.events.CloseEvent;
import mx.events.FlexEvent;
import mx.managers.PopUpManager;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

import org.bishow.component.PopManager;//引入弹出窗口管理器
import org.bishow.modules.chartCenter.global.GlobalFunc;//引入全局控制类
import org.bishow.modules.publicButton;//引入模块页眉页脚
import org.bishow.modules.medicalSecurity; //引入医疗保障模块
import org.bishow.modules.ChartCenter; //引入综合管理模块
import org.bishow.modules.DrugManagement; //引入药品管理模块
import org.bishow.modules.PublicHealthDataAnalysis; //引入公共卫生模块
import org.bishow.modules.MedicalServiceDataAnalysis; //引入药品管理模块
import org.bishow.modules.whiteboard; //引入远程会议模块
import org.bishow.modules.Resource; //引入区域概况模块
import org.bishow.modules.hospitalResource;//引入综合医院模块
import org.bishow.modules.communityResource;//引入社区卫生模块
import org.bishow.modules.townshipResource;//引入乡镇卫生院模块
import org.bishow.modules.supervisionResource;//引入卫生监督和疾控中心模块

//import org.bishow.modules.CBCResource;
//import org.bishow.modules.areaResource;
//import org.bishow.modules.hospitalResource1;
//import org.bishow.modules.dataAnalysis;
//import org.bishow.modules.hygieneResource; import org.bishow.tools.HttpServiceForPost;

import spark.modules.Module;

//组件实例
private var uiComponent:UIComponent;

//当前载入模块对象
private var currentObject:Module;

[Bindable]
private var IsDemo:Boolean = false;

//容器宽度\高度
private var containerWidth:Number;
private var containerHeight:Number;

//全局参数

public var GF:GlobalFunc;

[Bindable]
public var imgPath:String;

[Bindable]
public var iconPosition:XMLList;

//xml中的item数组
public var config:XMLList;


public var objectArray:Array;

public var i:Number = 0;

//触发器,图片自动翻页
public var timer:Timer;

//当前版本
[Bindable]
public var currentEdition:String;
/**
 * 
 * 加载初始化信息方法组=======================================================================
 *     
 */ 
public function init():void
{
GF = GlobalFunc.getGf();//获取静态全局控制类对象
initConfig.url="assets/xml/init.xml";
initConfig.send();

}
/**
 * xml成功返回方法
 */ 
protected function initConfig_resultHandler(event:ResultEvent):void
{

GF.initConfig = XML(event.result);
//确定当前版本
currentEdition = GF.initConfig.init.currentEdition;

//读取与当前版本匹配的配置信息
config = XML(GF.initConfig).init.edition[currentEdition];

GF.imgPath = config.imgpath;

imgPath = config.imgpath;
iconPosition = config.iconPosition;


containerCroll.width = config.scrollerWidth;
containerCroll.height = config.scrollerHeight;

//加载背景图片---------------------------------------------------
objectArray = new Array();
for(var i:int = 0;i<config.containerBg.length();i++)
{
objectArray.push(config.containerBg[i]);
}
}
/**
 * xml调取错误方法
 */ 
protected function initConfig_faultHandler(event:FaultEvent):void
{
trace(event.fault.faultString);

}

/**
 * 
 *程序加载完后,设置页面信息=============================================================================== 
 **/
protected function applicationCompleteHandler(event:FlexEvent):void
{

//设定页面信息
this.width = config.width;
this.height = config.height;
containerWidth = config.width;
containerHeight = config.height;
GF.IsDemo = config.isDemo;

if(config.FULL_SCREEN == true)
{
//全屏显示
stage.displayState= StageDisplayState.FULL_SCREEN;
}
}

/**
 *
 *  页面初始动画、事件加载====================================================================== 
 * 
 **/
public function loadComplete():void
{
//启用手势
Multitouch.inputMode = MultitouchInputMode.GESTURE;
if(Multitouch.supportsGestureEvents==true)
{

trace("Multitouch.supportsGestureEvents="+Multitouch.supportedGestures);
}
else
{
trace("supportsGestureEvents is NO");
}
//是否支持触控事件
if(Multitouch.supportsTouchEvents==true)
{
trace("Multitouch.supportsTouchEvents="+Multitouch.supportsTouchEvents)
}
else
{
trace("supportsTouchEvents is NO");
}
//设置背景
switchBg(0);


PopManager.removePopAll();

//初始化页面动画-----------------------------------------
TweenMax.to(container, 1, {alpha:0, ease:Cubic.easeOut,onComplete:OnCEvent} );
TweenMax.to(dmId, 2, {alpha:1, ease:Cubic.easeOut} );
dmId.doubleClickFlag  = false;
dmId.visible = true;
dmId.init();
} /**
 * 
 * 页面初始化方法,初始动画事件调用
 */ 
public function OnCEvent():void
{
// //实例弹出窗口
// var s:PopUpManager=new PopUpManager();
//初始清空舞台
container.removeAllElements();

}

/**
 * 
 * 设置当前状态,确定显示模块========================================================================
 * 
 */ 
public function setState(i:Number):void
{
//导航页面隐藏
TweenMax.to(dmId, 2, {alpha:0, ease:Cubic.easeOut,onComplete:_setState(i)} );
//主窗体载入
TweenMax.to(container, 2, {alpha:1, ease:Cubic.easeOut} );
}

/**
 * 
 * 设置当前状态,延续事件
 * 
 */ 
public function _setState(i:Number):void
{
//设置背景
switchBg(5); //隐藏导航
dmId.visible = false;

if(i == 1)
{//应急管理
currentObject = new medicalSecurity();
}
else if(i == 2)
{//综合管理
currentObject  = new ChartCenter(); }else if(i == 3)
{//药品管理
currentObject  = new DrugManagement();
}else if(i == 4)
{//公共卫生
currentObject  = new PublicHealthDataAnalysis();
}else if(i == 5)
{//医疗服务
currentObject  = new MedicalServiceDataAnalysis();
}else if(i == 6)
{//远程会议
currentObject  = new whiteboard();
}else if(i == 7)
{//区域资源
currentObject = new Resource();
}else if(i == 8)
{//综合医院
currentObject  = new hospitalResource();
}else if(i == 9)
{//社区服务
currentObject  = new communityResource();
}else if(i == 10)
{//乡镇医院
currentObject  = new townshipResource();
}else if(i == 11)
{//卫生监督
//currentObject  = new CBCResource();
currentObject  = new supervisionResource();
supervisionResource(currentObject).typeflag="WSJD";
}else if(i == 12)
{//疾控中心
currentObject  = new supervisionResource();
supervisionResource(currentObject).typeflag="JKZX";
} //载入模块参数设定,并载入到舞台---------
currentObject.width = containerWidth;
currentObject.height = containerHeight;
container.removeAllElements();
uiComponent = new UIComponent();
container.addElement(uiComponent);
uiComponent.addChild(currentObject);
uiComponent.width = containerWidth;
uiComponent.height = containerHeight;

}
/**
 * 
 * 切换背景的
 * 
 */ 
public function switchBg(i:Number):void
{ var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);

var request:URLRequest = new URLRequest(objectArray[i]);
loader.load(request); }

private function completeHandler(event:Event):void
{
var loader:Loader = Loader(event.target.loader);
var bitmap:Bitmap = Bitmap(loader.content);
bitmap.smoothing = true;

containerBg.setStyle("backgroundImage",bitmap);

}

/**
 * 
 * 退出
 * 
 */ 
public function exitPage():void
{
stage.nativeWindow.close(); }
]]>
</fx:Script>
<!--主舞台容器-->
<s:BorderContainer id="containerBg" x="0" y="0" width="100%" height="100%" backgroundColor="#137add">
<s:Scroller id="containerCroll">
<s:Group id="container" width="100%" height="100%">
</s:Group>
</s:Scroller>
</s:BorderContainer>
<modules:loadResources currentEdition="{currentEdition}"/><!--加载信息-->
<modules:defaultM id="dmId" width="100%" height="100%" alpha="0" imgPath="{imgPath}" iconPosition="{iconPosition}" /><!--导航首页-->
</s:WindowedApplication>
flex