/cutload/CutLoad/CutLoad.as
http://cutload.googlecode.com/ · ActionScript · 1917 lines · 1166 code · 11 blank · 740 comment · 150 complexity · 0e1b29791813e12ee684f96fbe709531 MD5 · raw file
- package CutLoad
- {
- import CutLoad.*;
- import CutLoad.components.CButton;
- import CutLoad.components.CPopup;
- import CutLoad.components.CPopupSpring;
- import CutLoad.components.CRender;
- import CutLoad.components.CTextField;
- import CutLoad.components.CTextInput;
- import CutLoad.components.CTip;
- import CutLoad.components.Skin;
- import CutLoad.components.container.Container;
- import CutLoad.components.container.ContainerH;
- import CutLoad.components.container.ContainerV;
- import CutLoad.components.loadbar.ILoadBar;
- import CutLoad.components.loadbar.Loadbar;
- import CutLoad.components.loadbar.LoadbarForCutLoad;
- import CutLoad.components.window.CAlert;
- import CutLoad.components.window.CWait;
- import CutLoad.components.window.CWindow;
- import CutLoad.components.window.CWindowTextArea;
- import CutLoad.cookies.*;
-
- import flash.display.BitmapData;
- import flash.display.InteractiveObject;
- import flash.display.Loader;
- import flash.display.LoaderInfo;
- import flash.display.MovieClip;
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageDisplayState;
- import flash.display.StageScaleMode;
- import flash.events.ContextMenuEvent;
- import flash.events.Event;
- import flash.events.IOErrorEvent;
- import flash.events.MouseEvent;
- import flash.events.ProgressEvent;
- import flash.events.SecurityErrorEvent;
- import flash.net.LocalConnection;
- import flash.net.URLRequest;
- import flash.system.ApplicationDomain;
- import flash.system.LoaderContext;
- import flash.text.TextFormat;
- import flash.ui.ContextMenu;
- import flash.ui.ContextMenuItem;
-
- /**
- * <p>?????</p>
- * ????????
- * <ul>
- * <li>??</li>
- * <li>????</li>
- * <li>?????????????????????</li>
- * <li>???????????????????????</li>
- * <li>???????</li>
- * </ul>
- * <p>???????:???CutLoad.getLayer(...)??</p>
- * <p>????????:????????????????????????????swf??????????????setLoadBarMainApp()?setLoadBar()?????????????????Base???????CutLoad.components.ILoadBar??</p>
- * @author smallerbird mail:smallerbird@gmail.com site:www.mkigm.com QQ?:49983196
- *
- */
- public class CutLoad extends MovieClip implements IBase
- {
- /**
- * ???,????:[???.????????]
- */
- public static var VERSION:String="CutLoad v0.20120328";
- //debug??
- protected static var DEBUG_MESSAGE:Array=new Array();
- //?????????
- protected static var DEBUG_MESSAGE_LENGTH:Number=8;
- protected static var DEBUG_JS:Number=0;
- protected static var DEBUG_PASSWORD:String="";
- //?????
- public static const NULLNO:Number=-100000;
- /**
- * ?????
- */
- protected var tipManagement:CTipManagement=null;
- //?????????????????????????
- protected var tipNoStageManagement:CTipManagement=null;
- //??
- protected var spWatermark:Sprite
- //?????
- protected var Popup:CPopup;
- //??
- protected var spTop:Sprite=null;
- //?????????
- protected var containerAlign:Container;
- //?????
- protected var spFrameParent:Sprite;
- //????
- protected var spBak:CRender;
- //????
- protected var mainSwfName:String="";
- //?????????
- protected var arrResize:Array;
- //???????????????
- protected var funResizeDo:Function=null;
- //???????????????????????
- protected var isAutoResizeWH:Boolean=true;
- //??-------------------------------------------------------------------------------start
- protected var loadBar:ILoadBar=null;
- protected var clone_loadBar:ILoadBar=null;
- //????????
- protected var arrLibList:Array;
- //????????
- protected var arrLibListIndex:Number=0;
- //??????????
- protected var isLoadMain:Boolean=false
- //?????swf???
- protected var nowLoadSwfName:String="";
- //????cutload???lib.swf
- protected var isLoadedLib:Number=0;
- //???????
- protected var currentModule:ModuleBase=null;
- //??cutload?ui
- protected var isNotUseUi:Boolean=false;
- //??????????
- protected var moduleData:CArray;
- protected var currentModuleData:ModuleData=null;
- protected var winDebug:CWindowTextArea=null;
- protected var cwindpwd:CWindow=null;
- //?????????
- private var isAppLoadCmpt:Boolean=false;
- private var LoadBarMainApp_x:Number=0;
- private var LoadBarMainApp_y:Number=0;
- //?????????
- private var loadBarModule_x:Number=0;
- private var loadBarModule_y:Number=0;
- //????
- private var PopupMode:Number;
- //
- /**
- * ??????
- */
- protected var minStageWidth:Number=0,minStageHeight:Number=0;
- /**
- * ??????
- */
- protected var maxStageWidth:Number=0,maxStageHeight:Number=0;
- //?????????????????????
- private var updateBackForDepath:Sprite;
- //??????????????????swf?????????????????????????????swf?????"???.swf?v=xxx"
- private var appVersion:String;
- //????debug??
- private var isShowDebugMenu:Boolean;
- protected var menuDebug:ContextMenuItem ;
- protected var menuDebug_clr:ContextMenuItem;
- //????????????????????????????????cutload???????????????????????????????
- private var Layer5_index:Number=-1000;
- //??????
- protected var spWatermark_index:Number;
- protected var tipManagement_index:Number;
- protected var tipNoStageManagement_index:Number;
- protected var Popup_index:Number;
- protected var spTop_index:Number;
- protected var containerAlign_index:Number;
- protected var spFrameParent_index:Number;
- protected var spBak_index:Number;
- //
- protected var config:Config;
- /**
- * ???
- *
- */
- public function CutLoad()
- {
- this.addEventListener(Event.ADDED_TO_STAGE,addToStage);
- //
- funLoadModuleSwfCompt=function():void{}
- config=getConfig();
- }
- /**
- * cutload??????????????????????cutload?????????????????
- * @return
- *
- */
- protected function getConfig():Config{
- return new Config();
- }
- //????????
- private function addToStage(e:Event):void{
- tipManagement_index=tipNoStageManagement_index=Popup_index=spTop_index=containerAlign_index=spFrameParent_index=spBak_index=-1;
- //
- isShowDebugMenu=false;
- //????????
- if(!is_NOT_DIY_contextMenu()){
- var cm : ContextMenu = new ContextMenu();
- cm.hideBuiltInItems();
- cm.customItems=new Array();
- this.contextMenu=cm;
- menuDebug= new ContextMenuItem("show debug message",false);
- menuDebug.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menu_debug_onselect);
- //
- this.contextMenu.customItems.push(menuDebug);
- this.contextMenu.customItems.push(menuDebug_clr);
- }
- //
- var strTem123:String="?0?!!! "+VERSION;
- trace(strTem123);
- //debug(strTem123,1);
- strTem123="smallerbird www.mkigm.com";
- //debug(strTem123,1);
- trace(strTem123);
- strTem123="---------------------------------";
- //debug(strTem123,1);
- trace(strTem123);
- if(is_NO_SCALE_TOP_LEFT()){
- stage.scaleMode=StageScaleMode.NO_SCALE;
- stage.align=StageAlign.TOP_LEFT;
- }
- stage.stageFocusRect = false;
- arrLibList=[getCutLoadLibPath(),"Load Lib ",getCutLoadUIPath(),"Load UI "];
- VersionMyApp="";
- //????
- spWatermark=new Sprite();
- //
- updateBackForDepath=new Sprite();
- this.addChild(updateBackForDepath);
- //
- moduleData=new CArray();
- //?????????????flash ide??????
- if(this.totalFrames>1){
- debug("flash ide???????????????????????stop()",2);
- //?????
- this.addFrameScript(1,cutloadMainClass_for_frame2);
- }
- PopupMode=config.CutLoad_PopupMode();
- //
- //
- //
- debug("?? initOther()",1);
- initOther();
- //
- //
- //
- this.stage.addEventListener(Event.RESIZE,funResize_for_setLoadBarMainAppCenterXY);
- funResize_for_setLoadBarMainAppCenterXY(null);
- //
- //
- //????????????????isLoadCompleteDo()?????true??????????????????????????????????????????????
- if(loadBar!=null) if(loadBar.isLoadCompleteDo()) loadBar.setLoadCompleteDo(appLoadCompt_do);
- //
- if(loaderInfo.bytesLoaded==loaderInfo.bytesTotal){
- //???????????????
- //debug("??????????????",2);
- LoadAppCompleteChekDo();
- }else{
- loaderInfo.addEventListener(ProgressEvent.PROGRESS,appLoadProgress);
- loaderInfo.addEventListener(Event.COMPLETE,appLoadCompt);
- }
- }
- /**
- * ?????????????????????????????
- * @return true ??????????? false ???
- *
- */
- protected function is_NO_SCALE_TOP_LEFT():Boolean{
- return true;
- }
- /**
- * ??cutload?????????
- * @return false??? true???
- *
- */
- protected function is_NOT_DIY_contextMenu():Boolean{
- return false;
- }
- /**
- * ??cutload ?????lib.swf ???????:????lib.swf
- * @return
- *
- */
- protected function getCutLoadLibPath():String{
- return myURLPath+"lib";
- }
- /**
- * ??cutload ?????ui.swf ???????:????lib.swf
- * @return
- *
- */
- protected function getCutLoadUIPath():String{
- return myURLPath+"ui";
- }
- private function cutloadMainClass_for_frame2():void{
- if(!isAppLoadCmpt){
- stop();
- if(loadBar!=null){
- //trace("??????");
- var temLoadBar:Sprite=loadBar as Sprite;
- var spForTop:Sprite=new Sprite();
- this.addChild(spForTop);
- this.swapChildren(temLoadBar,spForTop);
- this.removeChild(spForTop);
- }
- debug("?? frame2_do()");
- frame2_do();
- }
- }
- /**
- * ?????????????????????????
- *
- */
- protected function frame2_do():void{
- }
- /**
- * ????
- *
- */
- public function FULL_SCREEN_ENABLE(isOk:Boolean=true):void{
- if(stage==null) return;
- try{
- if(isOk){
- stage.displayState = StageDisplayState.FULL_SCREEN;
- }else{
- stage.displayState = StageDisplayState.NORMAL;
- }
-
- }catch(e:SecurityError){
-
- }
-
- }
- /**
- *
- * @param str ????????
- * @return
- *
- */
- public function set VersionMyApp(str:String):void{
- this.appVersion=str;
- }
- /**
- * ??/????????????????????swf?????????????????????????????swf?????"???.swf?v=xxx"
- * @return
- *
- */
- public function get VersionMyApp():String{
- return appVersion;
- }
- //???????
- private function appStart():void{
- //?????????????????????
- this.stage.removeEventListener(Event.RESIZE,funResize_for_setLoadBarMainAppCenterXY);
- //
- //???
- createLoadBar(false);
- var temLoadBar:Base=loadBar as Base;
- loadBar.showHide(false);
- //
- LoadBarMainApp_x=loadBarModule_x;
- LoadBarMainApp_y=loadBarModule_y;
- //
- temLoadBar.setXY(LoadBarMainApp_x,LoadBarMainApp_y,this);
- this.init();
- }
- //
- private var setLoadBarMainAppCenter_isOk_v:Boolean=false;
- private var setLoadBarMainAppCenter_isOk_h:Boolean=false;
- /**
- * ???????????,????,???????????????????????????????LoadBarMainAppResize???????????????????
- * @param hCenter
- * @param vCenter
- *
- */
- public function setLoadBarMainAppCenter(hCenter:Boolean=true,vCenter:Boolean=true):void{
- setLoadBarMainAppCenter_isOk_v=vCenter;
- setLoadBarMainAppCenter_isOk_h=hCenter;
- }
- //?? ?????????,????
- private function setLoadBarMainAppCenterXY():void{
- var temLoadBar:Sprite=loadBar as Sprite;
- if(setLoadBarMainAppCenter_isOk_h) temLoadBar.x=(this.stage.stageWidth-temLoadBar.width)/2;
- if(setLoadBarMainAppCenter_isOk_v) temLoadBar.y=(this.stage.stageWidth-temLoadBar.height)/2;
- }
- /**
- * ??????????????????????????????????????????????
- * @param stageWidth
- * @param stageHeight
- * @param loadBar
- *
- */
- protected function LoadBarMainAppResize(stageWidth:Number,stageHeight:Number,loadBar:ILoadBar):void{
-
- }
- /**
- * ??????????????????????????????????????????????????
- * @param stageWidth
- * @param stageHeight
- * @param loadBar
- *
- */
- protected function LoadBarModuleAppResize(stageWidth:Number,stageHeight:Number,loadBar:ILoadBar):void{
- }
- //????????????????????????????cutload???????????
- private function funResize_for_setLoadBarMainAppCenterXY(e:Event):void{
- if(loadBar!=null&&stage!=null){
- if(setLoadBarMainAppCenter_isOk_v||setLoadBarMainAppCenter_isOk_h){
- //??????????
- setLoadBarMainAppCenterXY();
- }
- //??????????
- LoadBarMainAppResize(stage.stageWidth,stage.stageHeight,loadBar);
- }
-
- }
- /**
- * ???????????
- * @param newLoadbar ????????????????CutLoad.components.ILoadBar
- * @param xx ?????x
- * @param yy ?????y
- *
- */
- public function setLoadBarMainApp(newLoadbar:ILoadBar,xx:Number,yy:Number):void{
- //????????????????
- if(isAppLoadCmpt){
- CutLoad.CutLoad.debug("?????????? setLoadBarMainApp(.....)",2);
- return;
- }
- if(!(newLoadbar is Base)) throw new Error("?????????Base???????ILoadBar??");
- var temLoadBar:Sprite
- if(loadBar!=null){
- temLoadBar=loadBar as Sprite;
- this.removeChild(temLoadBar);
- loadBar=null;
- }
- LoadBarMainApp_x=xx;
- LoadBarMainApp_y=yy;
- loadBar=newLoadbar;
- temLoadBar=loadBar as Sprite;
- temLoadBar.x=xx;
- temLoadBar.y=yy;
- this.addChild(temLoadBar);
- cutloadMainClass_for_frame2()
- }
- /**
- * ?????
- * @param type 0:???????? 1:?????????
- *
- */
- public function setPopupMode(type:Number=0):void{
- if(type==0){
- this.PopupMode=0;
- }else{
- this.PopupMode=1;
- }
- }
- /**
- * ????
- *
- */
- public static function OptimizeMemory():void{
- debug("????:CutLoad.OptimizeMemory()",1);
- try{
- new LocalConnection().connect("www_mkigm_com_forOptimize_asdf");
- new LocalConnection().connect("www_mkigm_com_forOptimize_asdf");
- }catch(error : Error){
- }
- }
- /**
- * ??????
- * @param str ????
- * @param type ???? 0??????? 1:??,2:??
- *
- */
- public static function debug(str:String,type:Number=0):void{
- if(DEBUG_MESSAGE.length>=DEBUG_MESSAGE_LENGTH){
- //?????????????
- DEBUG_MESSAGE.shift();
- }
- DEBUG_JS++;
- switch(type){
- case 1:
- trace("??:"+str);
- str=DEBUG_JS+" : <font color=\"#0000FF\"><b>?? </b>"+str+"</font>";
- break;
- case 2:
- trace("??:"+str);
- str=DEBUG_JS+" : <font color=\"#FF0000\"><b>?? </b>"+str+"</font>";
- break;
- default:
- trace("??:"+str);
- str=DEBUG_JS+" : <font color=\"#666666\"><b>?? </b>"+str+"</font>";
- break;
- }
- DEBUG_MESSAGE.push("<br>"+str);
- }
- /**
- * ??????
- * @param str
- * @return
- *
- */
- public static function setDebugPWD(str:String):void{
- DEBUG_PASSWORD=str;
- }
- /**
- * ???????????
- *
- */
- public static function setDebugMsgLength(num:Number):void{
- DEBUG_MESSAGE_LENGTH=num;
- }
- /**
- * ???SWF ??????? ,??root.loaderInfo.parameters???.
- * <p>???SWF ?????????????????????flash???????<param name=flashvars value=xxxxx? /></p>
- * @return
- *
- */
- public function getFlashvars():Object{
- return root.loaderInfo.parameters;
- }
- /**
- * ????debug??
- * @param isDebug true???,false???
- *
- */
- public function set debugEnabled(isDebug:Boolean):void{
- if(isDebug){
- if(menuDebug!=null) return;
- }else{
- //???????????
- if(isShowDebugMenu){
- if(menuDebug!=null){
- for(var i:Number=0;i<this.contextMenu.customItems.length;i++){
- if(this.contextMenu.customItems[i]==menuDebug){
- this.contextMenu.customItems.splice(i,1);
- this.contextMenu.customItems.splice(i,1);
- menuDebug=null;
- menuDebug_clr=null;
- break;
- }
- }
- }
- }
- }
- isShowDebugMenu=isDebug;
- }
- /**
- * ???????????????????????hideBuiltInItems???????cutload.debugEnabled(true) ?????????????,??????????
- * @return
- *
- */
- public function getMenuCustomItems():Array{
- return this.contextMenu.customItems;
- }
- /**
- * ????????
- *
- */
- public function showDebugWin():void{
- if(isNotUseUi){
- return;
- }
- if(cwindpwd!=null) return;
- cwindpwd=new CWindow();
- cwindpwd.init("?????",true,true,false,270,60);
- cwindpwd.setFunCloseBtn(function():void{
- getLayer2_popup().removeTop();
- cwindpwd=null;
- });
- var ctem:ContainerH=new ContainerH();
- ctem.init({w:300,isAuto:false,xspace:5,yspace:5});
- var txtpwd:CTextInput=CTextInput.getSimple();
- txtpwd.setIsPwd(true);
- txtpwd.setWH(200,20);
- var btnpwdLogin:CButton=CButton.getSimpleBtn("??");
- btnpwdLogin.setOtherInfo({txtPwd:txtpwd});
- btnpwdLogin.addEventListener(MouseEvent.CLICK,function(e:MouseEvent):void{
- var obj:CTextInput=e.target.getOtherInfo().txtPwd;
- if(obj.text==DEBUG_PASSWORD){
- getLayer2_popup().removeTop();
- showDebugWin_msg();
- }else{
- alert(":(","debug pwd wrong!!!");
- }
- });
- ctem.appendSome([txtpwd,btnpwdLogin]);
- cwindpwd.getContainer().append(ctem);
- this.getLayer2_popup().popup(cwindpwd);
- }
- /**
- * ??debug??
- * @return
- *
- */
- public static function getDebugMsg():String{
- var strReturn:String="";
- for(var i:Number=0;i<DEBUG_MESSAGE.length;i++){
- strReturn+=DEBUG_MESSAGE[i]
- }
- return strReturn;
- }
- /**
- * ???????
- *
- */
- public function showDebugWin_msg():void{
- if(winDebug!=null) return;
- winDebug=new CWindowTextArea();
- winDebug.init("?????? :)___",true,false,false,this.getShowWidth()-100,this.getShowHeight()-100);
- winDebug.getPartWindow().getContainer().setBakColor(0xffffff,1);
- winDebug.htmlText=getDebugMsg();
- winDebug.getTextArea().getScroll().moveBarEnd();
- winDebug.setFunClose(closeWinDebug);
- this.getLayer2_popup().popup(winDebug);
- }
- //????????
- private function menu_debug_onselect(e:ContextMenuEvent):void{
- showDebugWin();
- }
- private function closeWinDebug(me:CWindowTextArea):void{
- this.getLayer2_popup().removeTop();
- winDebug=null;
- cwindpwd=null;
- }
- /**
- * ?????????????swf???. ?:???????lib.swf???(?????)??????cutload???????????????
- * ???????swf???????????????cutload.init(...)??????
- * @param swfname ??????? ,?????????".swf"
- * @param describe ?????????
- *
- */
- public function addLoadLibList(swfname:String,describe:String):void{
- arrLibList.push(swfname);
- arrLibList.push(describe);
- }
- //???????
- private function appLoadProgress(the:ProgressEvent):void {
- //trace("appLoadProgress:::"+(the.bytesLoaded/the.bytesTotal));
- if(loadBar!=null){
- loadBar.setValue(the.bytesLoaded/the.bytesTotal,"");
- }
- }
- /**
- * ??????????
- * @return
- *
- */
- public function get myURL():String{
- if(this.loaderInfo==null) return "";
- if(this.loaderInfo.url==null) return "";
- return this.loaderInfo.url;
- }
- /**
- * ??????????
- * @return
- *
- */
- public function get myURLPath():String{
- //return "http://balala.auldey.com/balala_addSoud/";
- var urlTem:String=myURL;
- if(urlTem=="") return "";
- return Fun.getFilePathStr(urlTem);
- }
- /**
- * ??????????????????????
- *
- */
- protected function LoadAppCompleteChekDo():void{
- if(loadBar!=null){
- if(loadBar.isLoadCompleteDo()){
- loadBar.loadComplete();
- }else{
- appLoadCompt_do();
- }
- }else{
- appLoadCompt_do();
- }
- }
- //???????
- private function appLoadCompt(e:Event):void{
- //
- //trace("???????");
- LoadAppCompleteChekDo();
- //
- }
- private function appLoadCompt_do():void{
- //trace("appLoadCompt_do");
- isAppLoadCmpt=true;
- root.loaderInfo.removeEventListener(ProgressEvent.PROGRESS,appLoadProgress);
- root.loaderInfo.removeEventListener(Event.COMPLETE,appLoadCompt);
- //???????????????????????????????????
- if(loadBar!=null){
- var loadBarBase:Sprite=loadBar as Sprite;
- if(loadBarBase!=null) if(loadBarBase.parent==this) this.removeChild(loadBarBase);
- loadBar=null;
- }
- if(this.totalFrames>1){
- play();
- if(whenAppLoadCompt!=null) whenAppLoadCompt();
- }
- appStart();
- }
- //???????????????????
- private var whenAppLoadCompt:Function=null
- /**
- * ???????????????????,?????????????????????????????????????????????????stop,???????????????????play???????????????????????????????
- * @param fun ????? ???function()
- *
- */
- public function setFunWhenAppLoadCompt(fun:Function):void{
- if(this.totalFrames==1){
- CutLoad.CutLoad.debug("CutLoad.setFunWhenAppLoadCompt(...) ??????????????????!",2);
- return;
- }
- whenAppLoadCompt=fun;
- }
- //?????????cutload?????????
- private function init():void{
- //
- init_noLoadLib();
- //??????????
- if(isNotUseUi){
- this.setLayerChildIndex_allTop();
- this.main();
- return;
- }
- //
- load(arrLibList[arrLibListIndex++],arrLibList[arrLibListIndex++], 1);
- }
- /**
- * ????????????
- * <p>?????flash???????lib.fla??????????????lib.swf,???????????flash???lib.swf???????</p>
- * <p>????????????????????????????????</p>
- *
- */
- private function init_noLoadLib():void{
- stage.addEventListener(Event.RESIZE,funResize);
- iniDiv()
- }
- /**
- * ??cutload????????????????????????
- * @return
- *
- */
- public function initOther():void{
-
- }
- /**
- * ????????????????????????????????????????????????????????????????
- *
- */
- public function main():void{
- }
- /**
- * ????????????lib.swf,ui.swf,????????????cutload?ui????????????????????????????????????? ????????????????????????ui????????????????????????????
- *
- */
- public function doNotLoadDefaultLib():void{
- isNotUseUi=true;
- //???????????????lib.swf,ui.swf?????????true
- isLoadMain=true;
- }
- private function updateBack():void{
- if(spBak!=null){
- this.swapChildren(updateBackForDepath,spBak);
- this.removeChild(spBak);
- }
- spBak=new CRender();
- spBak.mouseChildren=false;
- spBak.mouseEnabled=false;
- if(bakSaveConfig_obj==null){
- bakSaveConfig_type=0;
- bakSaveConfig_obj={color:0xff0000,alpha:0,isBitmap:false};
- }
- spBak.mouseEnabled=false;
- spBak.mouseChildren=false;
- spBak.init(bakSaveConfig_way,bakSaveConfig_type,bakSaveConfig_obj,this.getShowWidth(),this.getShowHeight());
- this.addChild(spBak);
- this.swapChildren(updateBackForDepath,spBak);
- }
- //??????
- private function removeCurrentModule():void{
- if(currentModule!=null){
- currentModule.killMe();
- if(currentModule.parent!=null) spFrameParent.removeChild(currentModule);
- currentModule=null;
- }
- }
- //?????
- protected function iniDiv():void{
- this.funResizeDo=null;
- //
- arrResize=new Array();
- //??
- updateBack()
- //???????
- removeCurrentModule();
- if(spFrameParent!=null) this.removeChild(spFrameParent);
- spFrameParent=new Sprite();
- this.addChild(spFrameParent);
- //
- //??
- if(containerAlign!=null) this.removeChild(containerAlign);
- containerAlign=new Container();
- containerAlign.init({w:this.getShowWidth(),h:this.getShowHeight(),lt_transition:config.CutLoad_addAlign_transition()});
- containerAlign.clrBak();
- this.addChild(containerAlign);
- //??
- if(spTop!=null) this.removeChild(spTop);
- spTop=new Sprite();
- this.addChild(spTop);
- //??
- if(Popup!=null) this.removeChild(Popup);
- if(PopupMode==0){
- Popup=new CPopup();
- }else{
- Popup=new CPopupSpring();
- }
- Popup.init(this.getShowWidth(),this.getShowHeight());
- this.addChild(Popup);
- //????????
- if(loadBar!=null) addLoadBar();
- //????,??????
- if(tipNoStageManagement!=null){
- tipNoStageManagement.clearAll();
- Fun.setTopDepath(tipNoStageManagement);
- }
- if(tipManagement!=null){
- tipManagement.clearAll();
- Fun.setTopDepath(tipManagement);
- }
- //??
- if(spWatermark.parent!=null) this.removeChild(spWatermark);
- this.addChild(spWatermark);
- }
- /**
- * ?????
- * @return
- *
- */
- public function resetLayer():void{
- this.iniDiv();
- }
- /**
- * ???????,?????????
- * <ol><b>????</b>
- * <li>????????0????,5????</li>
- * <li>????????????????Sprite,??????????,?????????addChild(..)????????????????</li>
- * <li>????????????????Sprite,?????????????????????????????????????????CutLoad?????getLayer?????????</li>
- * </ol>
- * <ol><b>??????</b>
- * <li>0:????????[???CTipManagement]</li>
- * <li>1:????????[???CTipManagement]</li>
- * <li>2:??[???CPopup]</li>
- * <li>3:??[???Sprite]</li>
- * <li>4:?????????[???Container]</li>
- * <li>5:??????[???Sprite]</li>
- * <li>6:????[???CRender]</li>
- * </ol>
- * @param index
- * @return
- *
- */
- public function getLayer(index:Number):Sprite{
- if(index<0||index>6) throw new Error("?????????:0~6");
- switch(index){
- case -1:
- return spWatermark;
- case 0:
- return tipManagement;
- break;
- case 1:
- return tipNoStageManagement;
- break;
- case 2:
- return Popup;
- break;
- case 3:
- return spTop;
- break;
- case 4:
- return containerAlign;
- break;
- case 5:
- return spFrameParent;
- break;
- default:
- return spBak;
- break;
- }
- }
- /**
- * ?cutload????????????
- * @return
- *
- */
- public function setLayerChildIndex_allTop():void{
- spBak_index=Fun.setTopDepath(this.getLayer6_bak());
- spFrameParent_index=Fun.setTopDepath(this.getLayer5_module());
- containerAlign_index=Fun.setTopDepath(this.getLayer4_align());
- spTop_index=Fun.setTopDepath(this.getLayer3_top());
- Popup_index=Fun.setTopDepath(this.getLayer2_popup());
- tipNoStageManagement_index=Fun.setTopDepath(this.getLayer1_tipNoStageManagement());
- tipManagement_index=Fun.setTopDepath(this.getLayer0_tipManagement());
- spWatermark_index=Fun.setTopDepath(spWatermark);
- }
- /**
- * ?????????
- * @param tipManagement_index
- * @param tipNoStageManagement_index
- * @param Popup_index
- * @param spTop_index
- * @param containerAlign_index
- * @param spFrameParent_index
- * @param spBak_index
- * @return
- *
- */
- public function setLayerChildIndex(tipManagement_index:Number,
- tipNoStageManagement_index:Number,
- Popup_index:Number,
- spTop_index:Number,
- containerAlign_index:Number,
- spFrameParent_index:Number,
- spBak_index:Number
- ):void{
- this.tipManagement_index=tipManagement_index;
- this.tipNoStageManagement_index=tipNoStageManagement_index;
- this.Popup_index=Popup_index;
- this.spTop_index=spTop_index;
- this.containerAlign_index=containerAlign_index;
- this.spFrameParent_index=spFrameParent_index;
- this.spBak_index=spBak_index;
- updateLayerChildIndex();
- //
- }
- //????
- private function updateLayerChildIndex():void{
- if(tipManagement_index==-1){
- tipManagement_index=this.getChildIndex(getLayer0_tipManagement());
- }else{
- this.setChildIndex(this.getLayer0_tipManagement(),tipManagement_index);
- }
- if(tipNoStageManagement_index==-1){
- tipNoStageManagement_index=this.getChildIndex(getLayer1_tipNoStageManagement());
- }else{
- this.setChildIndex(this.getLayer1_tipNoStageManagement(),tipNoStageManagement_index);
- }
- if(Popup_index==-1){
- Popup_index=this.getChildIndex(getLayer2_popup());
- }else{
- this.setChildIndex(this.getLayer2_popup(),Popup_index);
- }
- if(spTop_index==-1){
- spTop_index=this.getChildIndex(getLayer3_top());
- }else{
- this.setChildIndex(this.getLayer3_top(),spTop_index);
- }
- if(containerAlign_index==-1){
- containerAlign_index=this.getChildIndex(getLayer4_align());
- }else{
- this.setChildIndex(this.getLayer4_align(),containerAlign_index);
- }
- if(spFrameParent_index==-1){
- spFrameParent_index=this.getChildIndex(getLayer5_module());
- }else{
- this.setChildIndex(this.getLayer5_module(),spFrameParent_index);
- }
- if(spBak_index==-1){
- spBak_index=this.getChildIndex(getLayer6_bak());
- }else{
- this.setChildIndex(this.getLayer6_bak(),spBak_index);
- }
- }
- /**
- * ????
- * @param sp
- *
- */
- public function WatermarkAppend(sp:Sprite):void{
- this.spWatermark.addChild(sp);
- }
- /**
- * ???? ??
- * @param str ????
- * @param align ?????0?,1?,2?
- * @param color ??
- * @param size ???
- * @return
- *
- */
- public function WatermarkTxtAppend(str:String,align:uint=0,color:Number=0xff0000,size:Number=13):CTextField{
- var fmt:TextFormat=CTextField.getTextFormat(align,color,size);
- var txtTem:CTextField=CTextField.getSimpleTxt(str,fmt);
- WatermarkAppend(txtTem);
- return txtTem
- }
- /**
- * ??????
- *
- */
- public function WatermarkAppendClrAll():void{
- if(this.spWatermark==null) return;
- if(this.spWatermark.parent!=null){
- this.removeChild(this.spWatermark);
- this.spWatermark=null;
- }
- spWatermark=new Sprite();
- this.addChild(this.spWatermark);
- }
- /**
- * ???0,???CutLoad.getLayer(..)????????
- * @see CutLoad.getLayer()
- * @return
- *
- */
- public function getLayer0_tipManagement():CTipManagement{
- return tipManagement;
- }
- /**
- * ???1,???CutLoad.getLayer(..)????????
- * @return
- *
- */
- public function getLayer1_tipNoStageManagement():CTipManagement{
- //if(tipNoStageManagement==null) throw new Error("?????????!");
- return tipNoStageManagement;
- }
- /**
- * ???2,???CutLoad.getLayer(..)????????
- * @return
- *
- */
- public function getLayer2_popup():CPopup{
- return Popup;
- }
- /**
- * ???3,???CutLoad.getLayer(..)????????
- * @return
- *
- */
- public function getLayer3_top():Sprite{
- return spTop;
- }
- /**
- * ???4,???CutLoad.getLayer(..)????????
- * @return
- *
- */
- public function getLayer4_align():Container{
- return containerAlign;
- }
- /**
- * ???5,???CutLoad.getLayer(..)????????
- * @return
- *
- */
- public function getLayer5_module():Sprite{
- return spFrameParent;
- }
- /**
- * ???6,???CutLoad.getLayer(..)????????
- * @return
- *
- */
- public function getLayer6_bak():CRender{
- return spBak;
- }
- /**
- * ????? ??,??cutLoad.refreshLayout()????????????????????????.
- * @param type 0?????????????1:??????????????,2:????? ?????0
- *
- */
- public function refreshTip(type:Number=0):void{
- if(type==0||type==2){
- if(tipManagement!=null) this.tipManagement.update();
- }
- if(type==1||type==2){
- if(tipNoStageManagement!=null) tipNoStageManagement.update();
- }
- }
- /**
- * ???????
- * @param base ?????????
- * @param content ?????
- * @param tipWidth ?????
- * @param isUpdateRect ??????????????????true,??????????????????????????????false,????????????true.
- *
- */
- public function tip(base:Sprite,content:String,tipWidth:Number=0,isUpdateRect:Boolean=true):void{
- iniTip()
- tipManagement.add(base,content,tipWidth,isUpdateRect);
- }
- //??? ???????
- private function iniTip():void{
- if(tipManagement==null){
- //??????
- tipManagement=new CTipManagement();
- this.addChild(tipManagement);
- tipManagement.init();
- }
- }
- /**
- * ??? ?????? ???????
- *
- */
- public function iniTipNoStageManagement():void{
- if(tipNoStageManagement==null){
- //??????
- tipNoStageManagement=new CTipManagement();
- this.addChild(tipNoStageManagement);
- tipNoStageManagement.init();
- tipNoStageManagement.stop();
- }
- }
- /**
- * ????????
- * @return
- *
- */
- public function getLoadBar():ILoadBar{
- return loadBar
- }
- //???????????
- private function addLoadBar():void{
- //???????????
- //trace("addLoadBar:LoadBarMainApp_x:"+LoadBarMainApp_x+" LoadBarMainApp_y:"+LoadBarMainApp_y);
- if(LoadBarMainApp_x==NULLNO&&LoadBarMainApp_y==NULLNO){
- this.addAlign((loadBar as Base));
- }else{
- this.getLayer4_align().appendXY(loadBar as Base,LoadBarMainApp_x,LoadBarMainApp_y);
- }
- }
- //?????
- private function createLoadBar(isAdd:Boolean=true):void{
- if(loadBar!=null){
- loadBar.showHide(true);
- //trace("loadBar.showHide(true);");
- return;
- }
- if(clone_loadBar==null){
- //clone_loadBar=new Loadbar(200,20,0x000000,12,0xffffff,1,1,0xcccccc,1,0x000000,1)
- clone_loadBar=new LoadbarForCutLoad();
- }
- loadBar=clone_loadBar.clone();
- //??????????????
- if(isAdd){
- addLoadBar()
- }
- }
- /**
- * ????????
- *
- */
- public function removeLoadBar():void{
- //trace("removeLoadBar ");
- loadBar.setValue(0,"");
- loadBar.showHide(false);
- }
- /**
- * ??????????
- * @param newLoadbar ????????????????CutLoad.components.ILoadBar
- * @param xxx ???????x???0?????????,?????CutLoad.CutLoad.NULLNO
- * @param yyy ???????y???0?????????,?????CutLoad.CutLoad.NULLNO
- *
- */
- public function setLoadBar(newLoadbar:ILoadBar,xxx:Number=0,yyy:Number=0):void{
- if(!(newLoadbar is Base)) throw new Error("?????????Base???????ILoadBar??");
- loadBarModule_x=xxx;
- loadBarModule_y=yyy;
- clone_loadBar=newLoadbar;
- }
-
- //
- private var bakSaveConfig_type:uint=0;
- private var bakSaveConfig_way:uint=0;
- private var bakSaveConfig_obj:Object=null;
- /**
- * ??????? CutLoad.components.CRender.init(...) ??
- * @param type
- * @param config
- *
- */
- public function setBak(way:uint,type:uint,config:Object):void{
- bakSaveConfig_obj=config;
- bakSaveConfig_type=type
- bakSaveConfig_way=way;
- updateBack();
- }
- /**
- * ??????
- * @param bakColor ???
- * @param bakAlpha ?????
- * @param isBitmap ???????????
- *
- */
- public function setColorBak(bakColor:Number,bakAlpha:Number=1,isBitmap:Boolean=false):void{
- setBak(0,0,{color:bakColor,alpha:bakAlpha,isBitmap:isBitmap});
- }
- /**
- * ??
- * @param fps
- *
- */
- public function set fps(f:Number):void{
- if(stage==null) return;
- stage.frameRate=f;
- }
- /**
- * ??
- * @return
- *
- */
- public function get fps():Number{
- if(stage==null) return 0;
- return stage.frameRate
- }
- //??-----------------------------------------------start------------------------------------------
- private var loadLibCompelet:Function=null;
- /**
- * ?????? ,??????????????????????
- * @param p_url SWF??,?????".swf"
- * @param loadbarTalkYou ??????????
- * @param loadLibCompelet ?????????,????????????????????????null.
- *
- */
- public function loadLibSwf(p_url : String,loadbarTalkYou:String="",loadLibCompelet:Function=null):void{
- if(loadLibCompelet==null) loadLibCompelet=function():void{};
- this.loadLibCompelet=loadLibCompelet;
- load(p_url,loadbarTalkYou,1);
- }
- //???????????????????????????----------------------------
- private var forLoader_load:Loader=null;
- private var forLoader_load_url:URLRequest=null;
- private var forLoader_load_context:LoaderContext=null;
- private var forLoader_load_i:Number=0;
- private var forLoader_load_icount:Number=5;
- //??????
- private function reLoad():void{
- forLoader_load_i++;
- if(forLoader_load_i<=forLoader_load_icount){
- if(forLoader_load!=null&&forLoader_load_url!=null&&forLoader_load_context!=null){
- debug("????:"+forLoader_load_url+" ==> ?"+forLoader_load_i+"?",1)
- forLoader_load.load(forLoader_load_url,forLoader_load_context);
- }
- }
- if(forLoader_load_i==forLoader_load_icount){
- forLoader_load_i=0;
- forLoader_load=null;
- forLoader_load_url=null;
- forLoader_load_context=null;
- }
- }
- /**
- * ??????????????????????????????????????????????cutload?????????????????5????????????
- * @param num
- *
- */
- public function setReLoadTimes(num:Number):void{
- forLoader_load_icount=num;
- }
- private var loadbarTalkYou:String="";
- /**
- * ??SWF
- *
- * @param p_url SWF??,?????".swf"
- * @param p_url ??????????
- * @param p_target ?????ApplicationDomain 1??,0??,2??
- */
- protected function load(p_url : String,loadbarTalkYou:String="", p_target:Number=0) : void
- {
- p_url=p_url+".swf";
- if(VersionMyApp!==""){
- p_url+="?"+VersionMyApp;
- }
- //trace("load....:::"+p_url)
- debug("[load] "+loadbarTalkYou+"--->"+p_url,1);
- nowLoadSwfName=p_url;
- if(loadbarTalkYou=="") loadbarTalkYou="Load:"+p_url+" ";
- this.loadbarTalkYou=loadbarTalkYou;
- //???????
- createLoadBar()
- loadBar.setValue(0,loadbarTalkYou);
- LoadBarModuleAppResize(this.getShowWidth(),this.getShowHeight(),loadBar);
- this.update();
- //
- var loader:Loader = new Loader();
- var context:LoaderContext = new LoaderContext();
- switch (p_target)
- {
- case 0 :
- context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
- break;
- case 1 :
- context.applicationDomain = ApplicationDomain.currentDomain;
- break;
- case 2 :
- context.applicationDomain = new ApplicationDomain();
- break;
- default:
- throw new Error("???????:1??,0??,2??");
- break;
- }
- this.initLoadEvent(loader.contentLoaderInfo);
- //
- forLoader_load=loader;
- forLoader_load_context=context;
- forLoader_load_url=new URLRequest(p_url);
- loader.load(forLoader_load_url, context);
- }
- //---------------------??????????----------------
- private var LoadModuleSwf_doThisLater_endDo_swfName:String;
- //?????????????????????????????????
- private function LoadModuleSwf_doThisLater_endDo_fun():void{
- LoadModuleSwf(LoadModuleSwf_doThisLater_endDo_swfName);
- }
- /**
- * ?????????????????????????????????
- * @param swfName
- *
- */
- public function LoadModuleSwf_doThisLater(swfName:String):void{
- //debug("LoadModuleSwf_doThisLater-->"+swfName);
- if(this.currentModule==null){
- LoadModuleSwf(swfName);
- return;
- }
- swfName=swfName.toLocaleLowerCase();
- if(swfName.indexOf(".swf")!=-1) throw new Error("???.swf");
- if(swfName==this.currentModuleData.url) return;
- LoadModuleSwf_doThisLater_endDo_swfName=swfName;
- this.currentModule.leaveMovieStart(LoadModuleSwf_doThisLater_endDo_fun);
- }
- //
- private var funLoadModuleSwfCompt:Function;
- /**
- * ?????????5?????????????CutLoad.getLayer()???
- * @param swfName swf?????????".swf"
- * @param describe ???? ?????????:"load:???.swf"
- * @param p_target ????0,?????1??,0??,2??
- * @param funLoadModuleSwfCompt ????????????
- * @param isOptimizeMemory ??????,?????
- * @return
- *
- */
- public function LoadModuleSwf(swfName:String,describe:String="",p_target:Number=0,funLoadModuleSwfCompt:Function=null,isOptimizeMemory:Boolean=true):void{
- debug("LoadModuleSwf -> :"+swfName);
- swfName=swfName.toLocaleLowerCase()
- if(swfName.indexOf(".swf")!=-1) throw new Error("???.swf");
- //
- if(currentModuleData!=null){
- if(currentModuleData.url==swfName){
- //??????????????
- debug("LoadModuleSwf ????",2);
- return;
- }
- }
- if(funLoadModuleSwfCompt!=null) this.funLoadModuleSwfCompt=funLoadModuleSwfCompt;
- //?????????????iniDiv()
- //if(isLoadMain) iniDiv();
- //????????
- var indexTem:Number=moduleData.seachOne(swfName,ModuleData.URL)
- if(indexTem==-1){
- currentModuleData=new ModuleData(swfName);
- //trace("LoadModuleSwf:"+currentModuleData);
- moduleData.add(currentModuleData);
- }else{
- currentModuleData=moduleData.getOne(indexTem) as ModuleData;
- }
- removeCurrentModule();
- //????
- load(swfName,describe, p_target);
- if(!isLoadMain) isLoadMain=true;
- if(isOptimizeMemory) OptimizeMemory();
- }
- /**
- * ???????????
- * @return
- *
- */
- public function delCurrentModuleSwf():void{
- if(isLoadMain) iniDiv();
- }
- /**
- * ???????????
- * @return
- *
- */
- public function getCurrentModule():ModuleBase{
- if(this.currentModule==null) throw new Error("???????????");
- return this.currentModule;
- }
- /**
- * ???????????
- * @param url ???,????:".swf"
- * @return
- *
- */
- public function ModuleDataGet(url:String):ModuleData{
- if(url.indexOf(".swf")!=-1) throw new Error("???.swf");
- var indexTem:Number=moduleData.seachOne(url,ModuleData.URL);
- if(indexTem==-1){
- throw new Error("?????????????????:"+url);
- }
- return (moduleData.getOne(indexTem) as ModuleData);
- }
- /**
- * ?? ????????
- * @param md ????
- *
- */
- public function ModuleDataCreate(md:ModuleData):void{
- if(ModuleDataHave(md)){
- throw new Error("?????????????????????????,??ModuleDataCreate()???");
- }
- moduleData.add(md);
- }
- /**
- * ?? ????????????
- * @param md
- * @return
- *
- */
- public function ModuleDataHave(md:ModuleData):Boolean{
- var indexTem:Number=moduleData.seachOne(md.url,ModuleData.URL);
- if(indexTem!=-1){
- return true;
- }
- return false;
- }
- /**
- * ??????????
- * @param swfname ??????".swf"
- *
- */
- public function ModuleDataClear(swfname:String):void{
- var indexTem:Number=moduleData.seachOne(swfname,ModuleData.URL,true);
- }
- /**
- * @private
- * ??????
- *
- * @param p_info ?????LoaderInfo
- */
- private function initLoadEvent(p_info:LoaderInfo) : void
- {
- p_info.addEventListener(ProgressEvent.PROGRESS, this.onProgress);
- p_info.addEventListener(Event.COMPLETE, this.onComplete);
- p_info.addEventListener(IOErrorEvent.IO_ERROR, this.onError);
- p_info.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
- }
- /**
- * @private
- * ??????
- *
- * @param p_info ?????LoaderInfo
- */
- private function removeLoadEvent(p_info : LoaderInfo) : void
- {
- p_info.removeEventListener(Event.COMPLETE, this.onComplete);
- p_info.removeEventListener(ProgressEvent.PROGRESS, this.onProgress);
- p_info.removeEventListener(IOErrorEvent.IO_ERROR, this.onError);
- p_info.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
- }
- /* ???? */
- private function onComplete(p_e : Event) : void
- {
- if(isLoadedLib<2){
- isLoadedLib++;
- }
- //
- var info : LoaderInfo = p_e.currentTarget as LoaderInfo;
- this.removeLoadEvent(info);
- //??????
- //this.removeLoadBar();
- //trace("isLoadMain:::"+isLoadMain);
- if(!isLoadMain){
- //??????
- debug("???????",1);
- if(this.loadBar!=null){
- if(this.loadBar.isLoadCompleteDo()) {
- loadBar.setLoadCompleteDo(function():void{
- removeLoadBar();
- //????????,????????main
- if(isLoadedLib==2) isLoadMain=true;
- if(isLoadMain){
- debug("???? main()",1);
- removeLoadBar();
- loadModuleComplete(2,info);
- }else{
- loadModuleComplete(1,info);
- }
- });
- }else{
- //???????????
- removeLoadBar();
- //????????,????????main
- if(isLoadedLib==2) isLoadMain=true;
- if(isLoadMain){
- debug("???? main()",1);
- removeLoadBar();
- loadModuleComplete(2,info);
- }else{
- loadModuleComplete(1,info);
- }
- }
- //
- //
- }
- }else{
- //??loadLibCompelet?null???????,???????????,
- if(loadLibCompelet==null){
- if(!(info.content is ModuleBase)){
- throw new Error("?????swf?????CutLoad.ModuleBase!!");
- }
- //??????
- //debug("???????",1);
- if(this.loadBar!=null){
- if(this.loadBar.isLoadCompleteDo()) {
- loadBar.setLoadCompleteDo(function():void{
- removeLoadBar();
- loadModuleComplete(3,info);
- });
- }else{
- //???????????
- removeLoadBar();
- loadModuleComplete(3,info);
- }
- }
- }else{
- //?????
- //debug("?????????",1);
- if(this.loadBar!=null){
- if(this.loadBar.isLoadCompleteDo()) {
- loadBar.setLoadCompleteDo(function():void{
- removeLoadBar();
- loadModuleComplete(4,info);
- });
- }else{
- //???????????
- removeLoadBar();
- loadModuleComplete(4,info);
- }
- }
- //
- }
- }
- }
- //???????????
- private function loadModuleComplete(type:uint,info:LoaderInfo):void{
- switch(type){
- case 1:
- //??????
- load(arrLibList[arrLibListIndex++],arrLibList[arrLibListIndex++], 1)
-
- break;
- case 2:
- //????
- this.setLayerChildIndex_allTop();
- this.main();
- break;
- case 3:
- //??????
- currentModule=info.content as ModuleBase;
- debug("cutload ???????????",2);
- currentModule.initData(this.currentModuleData);
- spFrameParent.addChild(currentModule);
- //????
- this.stage.focus=currentModule;
- funLoadModuleSwfCompt();
- set_containerAlign_currentModule();
- break;
- case 4:
- //???????????
- try{
- loadLibCompelet(info.content);
- }catch(e:ArgumentError){
- loadLibCompelet();
- }
- //???????????null
- loadLibCompelet=null;
- break;
- }
-
- }
- private function onProgress(p_e:ProgressEvent) : void
- {
- //trace("onProgress");
- if(loadBar!=null){
- loadBar.setValue(p_e.bytesLoaded/p_e.bytesTotal,loadbarTalkYou);
- }
- }
- private function onError(p_e : Event) : void
- {
- var strTem123:String="?? \""+nowLoadSwfName+"\"?? ???"
- //if(!isNotUseUi) this.alert("??!",strTem123);
- debug(strTem123,1)
- reLoad()
- //?????????????
- }
- //????---------------------------------------------------------------------------------------
- /**
- * ????????????????????
- * @param base
- * @param resizeWH ?????????????????0?????,1????,2????
- *
- */
- public function addResize(base:Base,resizeWH:Number=0):void{
- if(resizeWH!=0&&resizeWH!=1&&resizeWH!=1) throw new Error("???resizeWH?????????:0?????,1????,2????");
- arrResize.push({base:base,t:resizeWH});
- }
- /**
- * ??????????????????
- * @param fun ??:function();
- *
- */
- public function setFunResizeDo(fun:Function):void{
- funResizeDo=fun;
- }
- private function funResize(e:Event):void{
- LoadBarModuleAppResize(this.getShowWidth(),this.getShowHeight(),loadBar);
- if(isAutoResizeWH) update();
- }
- /**
- * ????????????????,CutLoad.setWH()
- * @param isOk
- *
- */
- public function set autoResizeWH(isOk:Boolean):void{
- isAutoResizeWH=isOk;
- }
- /**
- * ???????????,??????????????????
- * @param minW ???
- * @param minH ???
- *
- */
- public function setResizeMinWH(minW:Number,minH:Number):void{
- this.minStageWidth=minW;
- this.minStageHeight=minH;
- }
- /**
- * ??????????????????????
- * @param maxW ???? ????0????????????????????
- * @param maxH ???? ????0????????????????????
- *
- */
- public function setResizeMaxWH(maxW:Number=0,maxH:Number=0):void{
- this.maxStageWidth=maxW;
- this.maxStageHeight=maxH;
- }
- //??currentModule?????containerAlign?????????????setResizeMaxWH ?????
- private function set_containerAlign_currentModule():void{
- if(this.currentModule!=null){
- this.currentModule.x=containerAlign.x;
- this.currentModule.y=containerAlign.y;
- }
- }
- /**
- * ?????????? ????????????????????????????
- * @return
- *
- */
- public function get resizeMinWidth():Number{
- return minStageWidth
- }
- /**
- * ?????????? ????????????????????????????
- * @return
- *
- */
- public function get resizeMinHeight():Number{
- return minStageHeight
- }
- /**
- * ????????????????????????????? ???????????????CutLoad.autoResizeWH=true/false??
- * @param w
- * @param h
- *
- */
- public function setWH(w:Number=0, h:Number=0):void{
- if(w<this.minStageWidth) w=this.minStageWidth;
- if(h<this.minStageHeight) h=this.minStageHeight;
- //???????????,???????????????
- var containerAlign_w:Number=w;
- var containerAlign_h:Number=h;
- //trace("www:"+w+" this.maxStageWidth "+this.maxStageWidth);
- //trace("hhh:"+h+" this.maxStageHeight "+this.maxStageHeight)
- if(maxStageWidth>0){
- if(w>this.maxStageWidth){
- containerAlign_w=this.maxStageWidth;
- containerAlign.x=(this.getShowWidth()-containerAlign_w)/2;
- }else{
- containerAlign.x=0;
- }
- }
- if(maxStageHeight>0){
- if(h>this.maxStageHeight){
- containerAlign_h=this.maxStageHeight;
- containerAlign.y=(this.getShowHeight()-containerAlign_h)/2
- }else{
- containerAlign.y=0;
- }
- }
- //??????????
- if(this.minStageWidth>0){
- if(w<this.minStageWidth){
- containerAlign_w=minStageWidth;
- }
- }
- if(this.minStageHeight>0){
- if(h<this.minStageHeight){
- containerAlign_h=minStageHeight;
- }
- }
- containerAlign.setWH(containerAlign_w,containerAlign_h);
- //trace("containerAlign.setWH "+containerAlign_w+","+containerAlign_h);
- set_containerAlign_currentModule();
- //
- //
- //
- spBak.setWH(w,h);
- Popup.setWH(w,h);
- //
- var obj:Object;
- var baseTem:Base;
- for(var i:Number=0;i<arrResize.length;i++){
- obj=arrResize[i];
- baseTem=obj.base;
- if(obj.t==1){
- baseTem.setWH(w,baseTem.getShowWidth());
- }else if(obj.t==2){
- baseTem.setWH(baseTem.getShowWidth(),h);
- }else{
- baseTem.setWH(w,h);
- }
- }
- //??
- if(tipManagement!=null) this.tipManagement.update();
- //
- //
- if(funResizeDo!=null){
- funResizeDo();
- }
- if(currentModule!=null) currentModule.setWH(this.getShowWidth(),this.getShowHeight());
- }
- //????---------------------------------------------------------------------------------------
- /**
- * ??? ?
- *
- */
- private function update():void{
- setWH(getShowWidth(),getShowHeight());
- }
- /**
- * ??? ?
- * ???? update()
- */
- public function refreshLayout():void{
- update();
- }
- /**
- * ?????????,????:0??,1??,2??,3??,4??,5??,6??,7??,8??
- * @param base ????????
- * @param t ????:0??,1??,2??,3??,4??,5??,6??,7??,8??
- *
- */
- public function addAlign(base:Base,t:Number=0):void{
- containerAlign.append(base,true,{t:t});
- }
- /**
- * ??????????
- * @param base
- *
- */
- public function delAlign(base:Base):void{
- containerAlign.delChild(base);
- }
- //??-------------------------------------------------------------------------------------------------------------
- //??
- private var waitAlert:CWait
- //
- /**
- * ??????
- * @param contend ??
- * @param tile ??
- * @param t ??????????????0:???????0??,1??,2??,3??,4??,5??,6??,7??,8??,????????CutLoad.cookies.LayoutTable????
- *
- */
- public function wait(contend:String="",tile:String="???",t:Number=0,w:Number=0,h:Number=0):CWait{
- if(waitAlert==null){
- waitAlert=new CWait();
- waitAlert.init(contend,tile);
- }else{
- waitAlert.setTitle(tile);
- waitAlert.setContent(contend);
- }
- waitAlert.setWH(w,h);
- Popup.popup(waitAlert,t);
- return waitAlert;
- }
- /**
- * ??????
- *
- */
- public function closeWait():Boolean{
- if(waitAlert!=null){
- Popup.remove(waitAlert);
- waitAlert=null
- return true;
- }
- return false
- }
- /**
- * ????????
- * @return
- *
- */
- public function getWaitAlert():CWait{
- return waitAlert;
- }
- //??
- private var alert_ok_sendFun:Function;
- /**
- * ???
- * @param tile ??
- * @param contend ??
- * @param btnOkLable ???ok????????
- * @param fun ?????ok????????????null,??????fun();
- * @param t ??????????????0:???????0??,1??,2??,3??,4??,5??,6??,7??,8??,????????CutLoad.cookies.LayoutTable????
- *
- */
- public function alert(tile:String="",contend:String="",btnOkLable:String="OK",fun:Function=null,t:Number=0):CAlert{
- alert_ok_sendFun=fun;
- var cA:CAlert=new CAlert();
- cA.init(tile,contend,[btnOkLable],alert_click);
- Popup.popup(cA,t);
- return cA;
- }
- //???????????
- private function alert_click(id:Number=0):void{
- this.Popup.removeTop();
- if(alert_ok_sendFun!=null) alert_ok_sendFun();
- }
- //???,???
- private var confirm_ok_no_sendFun:Function;
- /**
- * ??????
- * @param tile ??
- * @param contend ??
- * @param btnOkLable ???ok????????
- * @param btnNoLable ???no????????
- * @param fun ??ok?no???????????null,???fun(?????ok:Boolean)
- * @param t ??????????????0:???????0??,1??,2??,3??,4??,5??,6??,7??,8??,????????CutLoad.cookies.LayoutTable????
- * @return
- */
- public function confirm(tile:String="",contend:String="",btnOkLable:String="OK",btnNoLable:String="NO",fun:Function=null,t:Number=0):CAlert{
- confirm_ok_no_sendFun=fun;
- var cA:CAlert=new CAlert();
- cA.init(tile,contend,[btnOkLable,btnNoLable],confirm_click);
- Popup.popup(cA,t);
- return cA
- }
- //
- private function confirm_click(id:Number):void{
- var isOk:Boolean=false
- if(id==0) isOk=true;
- this.Popup.removeTop();
- if(confirm_ok_no_sendFun!=null) confirm_ok_no_sendFun(isOk)
- }
- /**
- * ??????,???????????????????????????????????????????
- * @return
- *
- */
- public function getShowWidthComparisonMaxMin():Number{
- var ww:Number=this.getShowWidth();
- if(this.maxStageWidth!=0){
- if(ww>this.maxStageWidth) ww=this.maxStageWidth;
- if(ww<this.minStageWidth) ww=this.minStageWidth;
- }
- return ww;
- }
- /**
- * ??????,???????????????????????????????????????????
- * @return
- *
- */
- public function getShowHeightComparisonMaxMin():Number{
- var hh:Number=this.getShowHeight();
- if(this.maxStageHeight!=0){
- if(hh>this.maxStageHeight) hh=this.maxStageHeight;
- if(hh<this.minStageWidth) hh=this.minStageWidth;
- }
- return hh;
- }
- //??
- /**
- * ??????
- * @return
- *
- */
- public function getShowWidth():Number{
- if(stage==null) return 0
- return stage.stageWidth;
- }
- /**
- * ??????
- * @return
- *
- */
- public function getShowHeight():Number{
- if(stage==null) return 0;
- return stage.stageHeight;
- }
- /**
- * ????
- *
- */
- public function killMe():void{
- if(this.parent!=null) this.parent.removeChild(this);
- }
- }
- }