PageRenderTime 62ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/cutload/CutLoad/CutLoad.as

http://cutload.googlecode.com/
ActionScript | 1917 lines | 1166 code | 11 blank | 740 comment | 150 complexity | 0e1b29791813e12ee684f96fbe709531 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. package CutLoad
  2. {
  3. import CutLoad.*;
  4. import CutLoad.components.CButton;
  5. import CutLoad.components.CPopup;
  6. import CutLoad.components.CPopupSpring;
  7. import CutLoad.components.CRender;
  8. import CutLoad.components.CTextField;
  9. import CutLoad.components.CTextInput;
  10. import CutLoad.components.CTip;
  11. import CutLoad.components.Skin;
  12. import CutLoad.components.container.Container;
  13. import CutLoad.components.container.ContainerH;
  14. import CutLoad.components.container.ContainerV;
  15. import CutLoad.components.loadbar.ILoadBar;
  16. import CutLoad.components.loadbar.Loadbar;
  17. import CutLoad.components.loadbar.LoadbarForCutLoad;
  18. import CutLoad.components.window.CAlert;
  19. import CutLoad.components.window.CWait;
  20. import CutLoad.components.window.CWindow;
  21. import CutLoad.components.window.CWindowTextArea;
  22. import CutLoad.cookies.*;
  23. import flash.display.BitmapData;
  24. import flash.display.InteractiveObject;
  25. import flash.display.Loader;
  26. import flash.display.LoaderInfo;
  27. import flash.display.MovieClip;
  28. import flash.display.Sprite;
  29. import flash.display.StageAlign;
  30. import flash.display.StageDisplayState;
  31. import flash.display.StageScaleMode;
  32. import flash.events.ContextMenuEvent;
  33. import flash.events.Event;
  34. import flash.events.IOErrorEvent;
  35. import flash.events.MouseEvent;
  36. import flash.events.ProgressEvent;
  37. import flash.events.SecurityErrorEvent;
  38. import flash.net.LocalConnection;
  39. import flash.net.URLRequest;
  40. import flash.system.ApplicationDomain;
  41. import flash.system.LoaderContext;
  42. import flash.text.TextFormat;
  43. import flash.ui.ContextMenu;
  44. import flash.ui.ContextMenuItem;
  45. /**
  46. * <p>?????</p>
  47. * ????????
  48. * <ul>
  49. * <li>??</li>
  50. * <li>????</li>
  51. * <li>?????????????????????</li>
  52. * <li>???????????????????????</li>
  53. * <li>???????</li>
  54. * </ul>
  55. * <p>???????:???CutLoad.getLayer(...)??</p>
  56. * <p>????????:????????????????????????????swf??????????????setLoadBarMainApp()?setLoadBar()?????????????????Base???????CutLoad.components.ILoadBar??</p>
  57. * @author smallerbird mail:smallerbird@gmail.com site:www.mkigm.com QQ?:49983196
  58. *
  59. */
  60. public class CutLoad extends MovieClip implements IBase
  61. {
  62. /**
  63. * ???,????:[???.????????]
  64. */
  65. public static var VERSION:String="CutLoad v0.20120328";
  66. //debug??
  67. protected static var DEBUG_MESSAGE:Array=new Array();
  68. //?????????
  69. protected static var DEBUG_MESSAGE_LENGTH:Number=8;
  70. protected static var DEBUG_JS:Number=0;
  71. protected static var DEBUG_PASSWORD:String="";
  72. //?????
  73. public static const NULLNO:Number=-100000;
  74. /**
  75. * ?????
  76. */
  77. protected var tipManagement:CTipManagement=null;
  78. //?????????????????????????
  79. protected var tipNoStageManagement:CTipManagement=null;
  80. //??
  81. protected var spWatermark:Sprite
  82. //?????
  83. protected var Popup:CPopup;
  84. //??
  85. protected var spTop:Sprite=null;
  86. //?????????
  87. protected var containerAlign:Container;
  88. //?????
  89. protected var spFrameParent:Sprite;
  90. //????
  91. protected var spBak:CRender;
  92. //????
  93. protected var mainSwfName:String="";
  94. //?????????
  95. protected var arrResize:Array;
  96. //???????????????
  97. protected var funResizeDo:Function=null;
  98. //???????????????????????
  99. protected var isAutoResizeWH:Boolean=true;
  100. //??-------------------------------------------------------------------------------start
  101. protected var loadBar:ILoadBar=null;
  102. protected var clone_loadBar:ILoadBar=null;
  103. //????????
  104. protected var arrLibList:Array;
  105. //????????
  106. protected var arrLibListIndex:Number=0;
  107. //??????????
  108. protected var isLoadMain:Boolean=false
  109. //?????swf???
  110. protected var nowLoadSwfName:String="";
  111. //????cutload???lib.swf
  112. protected var isLoadedLib:Number=0;
  113. //???????
  114. protected var currentModule:ModuleBase=null;
  115. //??cutload?ui
  116. protected var isNotUseUi:Boolean=false;
  117. //??????????
  118. protected var moduleData:CArray;
  119. protected var currentModuleData:ModuleData=null;
  120. protected var winDebug:CWindowTextArea=null;
  121. protected var cwindpwd:CWindow=null;
  122. //?????????
  123. private var isAppLoadCmpt:Boolean=false;
  124. private var LoadBarMainApp_x:Number=0;
  125. private var LoadBarMainApp_y:Number=0;
  126. //?????????
  127. private var loadBarModule_x:Number=0;
  128. private var loadBarModule_y:Number=0;
  129. //????
  130. private var PopupMode:Number;
  131. //
  132. /**
  133. * ??????
  134. */
  135. protected var minStageWidth:Number=0,minStageHeight:Number=0;
  136. /**
  137. * ??????
  138. */
  139. protected var maxStageWidth:Number=0,maxStageHeight:Number=0;
  140. //?????????????????????
  141. private var updateBackForDepath:Sprite;
  142. //??????????????????swf?????????????????????????????swf?????"???.swf?v=xxx"
  143. private var appVersion:String;
  144. //????debug??
  145. private var isShowDebugMenu:Boolean;
  146. protected var menuDebug:ContextMenuItem ;
  147. protected var menuDebug_clr:ContextMenuItem;
  148. //????????????????????????????????cutload???????????????????????????????
  149. private var Layer5_index:Number=-1000;
  150. //??????
  151. protected var spWatermark_index:Number;
  152. protected var tipManagement_index:Number;
  153. protected var tipNoStageManagement_index:Number;
  154. protected var Popup_index:Number;
  155. protected var spTop_index:Number;
  156. protected var containerAlign_index:Number;
  157. protected var spFrameParent_index:Number;
  158. protected var spBak_index:Number;
  159. //
  160. protected var config:Config;
  161. /**
  162. * ???
  163. *
  164. */
  165. public function CutLoad()
  166. {
  167. this.addEventListener(Event.ADDED_TO_STAGE,addToStage);
  168. //
  169. funLoadModuleSwfCompt=function():void{}
  170. config=getConfig();
  171. }
  172. /**
  173. * cutload??????????????????????cutload?????????????????
  174. * @return
  175. *
  176. */
  177. protected function getConfig():Config{
  178. return new Config();
  179. }
  180. //????????
  181. private function addToStage(e:Event):void{
  182. tipManagement_index=tipNoStageManagement_index=Popup_index=spTop_index=containerAlign_index=spFrameParent_index=spBak_index=-1;
  183. //
  184. isShowDebugMenu=false;
  185. //????????
  186. if(!is_NOT_DIY_contextMenu()){
  187. var cm : ContextMenu = new ContextMenu();
  188. cm.hideBuiltInItems();
  189. cm.customItems=new Array();
  190. this.contextMenu=cm;
  191. menuDebug= new ContextMenuItem("show debug message",false);
  192. menuDebug.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,menu_debug_onselect);
  193. //
  194. this.contextMenu.customItems.push(menuDebug);
  195. this.contextMenu.customItems.push(menuDebug_clr);
  196. }
  197. //
  198. var strTem123:String="?0?!!! "+VERSION;
  199. trace(strTem123);
  200. //debug(strTem123,1);
  201. strTem123="smallerbird www.mkigm.com";
  202. //debug(strTem123,1);
  203. trace(strTem123);
  204. strTem123="---------------------------------";
  205. //debug(strTem123,1);
  206. trace(strTem123);
  207. if(is_NO_SCALE_TOP_LEFT()){
  208. stage.scaleMode=StageScaleMode.NO_SCALE;
  209. stage.align=StageAlign.TOP_LEFT;
  210. }
  211. stage.stageFocusRect = false;
  212. arrLibList=[getCutLoadLibPath(),"Load Lib ",getCutLoadUIPath(),"Load UI "];
  213. VersionMyApp="";
  214. //????
  215. spWatermark=new Sprite();
  216. //
  217. updateBackForDepath=new Sprite();
  218. this.addChild(updateBackForDepath);
  219. //
  220. moduleData=new CArray();
  221. //?????????????flash ide??????
  222. if(this.totalFrames>1){
  223. debug("flash ide???????????????????????stop()",2);
  224. //?????
  225. this.addFrameScript(1,cutloadMainClass_for_frame2);
  226. }
  227. PopupMode=config.CutLoad_PopupMode();
  228. //
  229. //
  230. //
  231. debug("?? initOther()",1);
  232. initOther();
  233. //
  234. //
  235. //
  236. this.stage.addEventListener(Event.RESIZE,funResize_for_setLoadBarMainAppCenterXY);
  237. funResize_for_setLoadBarMainAppCenterXY(null);
  238. //
  239. //
  240. //????????????????isLoadCompleteDo()?????true??????????????????????????????????????????????
  241. if(loadBar!=null) if(loadBar.isLoadCompleteDo()) loadBar.setLoadCompleteDo(appLoadCompt_do);
  242. //
  243. if(loaderInfo.bytesLoaded==loaderInfo.bytesTotal){
  244. //???????????????
  245. //debug("??????????????",2);
  246. LoadAppCompleteChekDo();
  247. }else{
  248. loaderInfo.addEventListener(ProgressEvent.PROGRESS,appLoadProgress);
  249. loaderInfo.addEventListener(Event.COMPLETE,appLoadCompt);
  250. }
  251. }
  252. /**
  253. * ?????????????????????????????
  254. * @return true ??????????? false ???
  255. *
  256. */
  257. protected function is_NO_SCALE_TOP_LEFT():Boolean{
  258. return true;
  259. }
  260. /**
  261. * ??cutload?????????
  262. * @return false??? true???
  263. *
  264. */
  265. protected function is_NOT_DIY_contextMenu():Boolean{
  266. return false;
  267. }
  268. /**
  269. * ??cutload ?????lib.swf ???????:????lib.swf
  270. * @return
  271. *
  272. */
  273. protected function getCutLoadLibPath():String{
  274. return myURLPath+"lib";
  275. }
  276. /**
  277. * ??cutload ?????ui.swf ???????:????lib.swf
  278. * @return
  279. *
  280. */
  281. protected function getCutLoadUIPath():String{
  282. return myURLPath+"ui";
  283. }
  284. private function cutloadMainClass_for_frame2():void{
  285. if(!isAppLoadCmpt){
  286. stop();
  287. if(loadBar!=null){
  288. //trace("??????");
  289. var temLoadBar:Sprite=loadBar as Sprite;
  290. var spForTop:Sprite=new Sprite();
  291. this.addChild(spForTop);
  292. this.swapChildren(temLoadBar,spForTop);
  293. this.removeChild(spForTop);
  294. }
  295. debug("?? frame2_do()");
  296. frame2_do();
  297. }
  298. }
  299. /**
  300. * ?????????????????????????
  301. *
  302. */
  303. protected function frame2_do():void{
  304. }
  305. /**
  306. * ????
  307. *
  308. */
  309. public function FULL_SCREEN_ENABLE(isOk:Boolean=true):void{
  310. if(stage==null) return;
  311. try{
  312. if(isOk){
  313. stage.displayState = StageDisplayState.FULL_SCREEN;
  314. }else{
  315. stage.displayState = StageDisplayState.NORMAL;
  316. }
  317. }catch(e:SecurityError){
  318. }
  319. }
  320. /**
  321. *
  322. * @param str ????????
  323. * @return
  324. *
  325. */
  326. public function set VersionMyApp(str:String):void{
  327. this.appVersion=str;
  328. }
  329. /**
  330. * ??/????????????????????swf?????????????????????????????swf?????"???.swf?v=xxx"
  331. * @return
  332. *
  333. */
  334. public function get VersionMyApp():String{
  335. return appVersion;
  336. }
  337. //???????
  338. private function appStart():void{
  339. //?????????????????????
  340. this.stage.removeEventListener(Event.RESIZE,funResize_for_setLoadBarMainAppCenterXY);
  341. //
  342. //???
  343. createLoadBar(false);
  344. var temLoadBar:Base=loadBar as Base;
  345. loadBar.showHide(false);
  346. //
  347. LoadBarMainApp_x=loadBarModule_x;
  348. LoadBarMainApp_y=loadBarModule_y;
  349. //
  350. temLoadBar.setXY(LoadBarMainApp_x,LoadBarMainApp_y,this);
  351. this.init();
  352. }
  353. //
  354. private var setLoadBarMainAppCenter_isOk_v:Boolean=false;
  355. private var setLoadBarMainAppCenter_isOk_h:Boolean=false;
  356. /**
  357. * ???????????,????,???????????????????????????????LoadBarMainAppResize???????????????????
  358. * @param hCenter
  359. * @param vCenter
  360. *
  361. */
  362. public function setLoadBarMainAppCenter(hCenter:Boolean=true,vCenter:Boolean=true):void{
  363. setLoadBarMainAppCenter_isOk_v=vCenter;
  364. setLoadBarMainAppCenter_isOk_h=hCenter;
  365. }
  366. //?? ?????????,????
  367. private function setLoadBarMainAppCenterXY():void{
  368. var temLoadBar:Sprite=loadBar as Sprite;
  369. if(setLoadBarMainAppCenter_isOk_h) temLoadBar.x=(this.stage.stageWidth-temLoadBar.width)/2;
  370. if(setLoadBarMainAppCenter_isOk_v) temLoadBar.y=(this.stage.stageWidth-temLoadBar.height)/2;
  371. }
  372. /**
  373. * ??????????????????????????????????????????????
  374. * @param stageWidth
  375. * @param stageHeight
  376. * @param loadBar
  377. *
  378. */
  379. protected function LoadBarMainAppResize(stageWidth:Number,stageHeight:Number,loadBar:ILoadBar):void{
  380. }
  381. /**
  382. * ??????????????????????????????????????????????????
  383. * @param stageWidth
  384. * @param stageHeight
  385. * @param loadBar
  386. *
  387. */
  388. protected function LoadBarModuleAppResize(stageWidth:Number,stageHeight:Number,loadBar:ILoadBar):void{
  389. }
  390. //????????????????????????????cutload???????????
  391. private function funResize_for_setLoadBarMainAppCenterXY(e:Event):void{
  392. if(loadBar!=null&&stage!=null){
  393. if(setLoadBarMainAppCenter_isOk_v||setLoadBarMainAppCenter_isOk_h){
  394. //??????????
  395. setLoadBarMainAppCenterXY();
  396. }
  397. //??????????
  398. LoadBarMainAppResize(stage.stageWidth,stage.stageHeight,loadBar);
  399. }
  400. }
  401. /**
  402. * ???????????
  403. * @param newLoadbar ????????????????CutLoad.components.ILoadBar
  404. * @param xx ?????x
  405. * @param yy ?????y
  406. *
  407. */
  408. public function setLoadBarMainApp(newLoadbar:ILoadBar,xx:Number,yy:Number):void{
  409. //????????????????
  410. if(isAppLoadCmpt){
  411. CutLoad.CutLoad.debug("?????????? setLoadBarMainApp(.....)",2);
  412. return;
  413. }
  414. if(!(newLoadbar is Base)) throw new Error("?????????Base???????ILoadBar??");
  415. var temLoadBar:Sprite
  416. if(loadBar!=null){
  417. temLoadBar=loadBar as Sprite;
  418. this.removeChild(temLoadBar);
  419. loadBar=null;
  420. }
  421. LoadBarMainApp_x=xx;
  422. LoadBarMainApp_y=yy;
  423. loadBar=newLoadbar;
  424. temLoadBar=loadBar as Sprite;
  425. temLoadBar.x=xx;
  426. temLoadBar.y=yy;
  427. this.addChild(temLoadBar);
  428. cutloadMainClass_for_frame2()
  429. }
  430. /**
  431. * ?????
  432. * @param type 0:???????? 1:?????????
  433. *
  434. */
  435. public function setPopupMode(type:Number=0):void{
  436. if(type==0){
  437. this.PopupMode=0;
  438. }else{
  439. this.PopupMode=1;
  440. }
  441. }
  442. /**
  443. * ????
  444. *
  445. */
  446. public static function OptimizeMemory():void{
  447. debug("????:CutLoad.OptimizeMemory()",1);
  448. try{
  449. new LocalConnection().connect("www_mkigm_com_forOptimize_asdf");
  450. new LocalConnection().connect("www_mkigm_com_forOptimize_asdf");
  451. }catch(error : Error){
  452. }
  453. }
  454. /**
  455. * ??????
  456. * @param str ????
  457. * @param type ???? 0??????? 1:??,2:??
  458. *
  459. */
  460. public static function debug(str:String,type:Number=0):void{
  461. if(DEBUG_MESSAGE.length>=DEBUG_MESSAGE_LENGTH){
  462. //?????????????
  463. DEBUG_MESSAGE.shift();
  464. }
  465. DEBUG_JS++;
  466. switch(type){
  467. case 1:
  468. trace("??:"+str);
  469. str=DEBUG_JS+" : <font color=\"#0000FF\"><b>?? </b>"+str+"</font>";
  470. break;
  471. case 2:
  472. trace("??:"+str);
  473. str=DEBUG_JS+" : <font color=\"#FF0000\"><b>?? </b>"+str+"</font>";
  474. break;
  475. default:
  476. trace("??:"+str);
  477. str=DEBUG_JS+" : <font color=\"#666666\"><b>?? </b>"+str+"</font>";
  478. break;
  479. }
  480. DEBUG_MESSAGE.push("<br>"+str);
  481. }
  482. /**
  483. * ??????
  484. * @param str
  485. * @return
  486. *
  487. */
  488. public static function setDebugPWD(str:String):void{
  489. DEBUG_PASSWORD=str;
  490. }
  491. /**
  492. * ???????????
  493. *
  494. */
  495. public static function setDebugMsgLength(num:Number):void{
  496. DEBUG_MESSAGE_LENGTH=num;
  497. }
  498. /**
  499. * ???SWF ??????? ,??root.loaderInfo.parameters???.
  500. * <p>???SWF ?????????????????????flash???????<param name=”flashvars” value=”xxxxx? /></p>
  501. * @return
  502. *
  503. */
  504. public function getFlashvars():Object{
  505. return root.loaderInfo.parameters;
  506. }
  507. /**
  508. * ????debug??
  509. * @param isDebug true???,false???
  510. *
  511. */
  512. public function set debugEnabled(isDebug:Boolean):void{
  513. if(isDebug){
  514. if(menuDebug!=null) return;
  515. }else{
  516. //???????????
  517. if(isShowDebugMenu){
  518. if(menuDebug!=null){
  519. for(var i:Number=0;i<this.contextMenu.customItems.length;i++){
  520. if(this.contextMenu.customItems[i]==menuDebug){
  521. this.contextMenu.customItems.splice(i,1);
  522. this.contextMenu.customItems.splice(i,1);
  523. menuDebug=null;
  524. menuDebug_clr=null;
  525. break;
  526. }
  527. }
  528. }
  529. }
  530. }
  531. isShowDebugMenu=isDebug;
  532. }
  533. /**
  534. * ???????????????????????hideBuiltInItems???????cutload.debugEnabled(true) ?????????????,??????????
  535. * @return
  536. *
  537. */
  538. public function getMenuCustomItems():Array{
  539. return this.contextMenu.customItems;
  540. }
  541. /**
  542. * ????????
  543. *
  544. */
  545. public function showDebugWin():void{
  546. if(isNotUseUi){
  547. return;
  548. }
  549. if(cwindpwd!=null) return;
  550. cwindpwd=new CWindow();
  551. cwindpwd.init("?????",true,true,false,270,60);
  552. cwindpwd.setFunCloseBtn(function():void{
  553. getLayer2_popup().removeTop();
  554. cwindpwd=null;
  555. });
  556. var ctem:ContainerH=new ContainerH();
  557. ctem.init({w:300,isAuto:false,xspace:5,yspace:5});
  558. var txtpwd:CTextInput=CTextInput.getSimple();
  559. txtpwd.setIsPwd(true);
  560. txtpwd.setWH(200,20);
  561. var btnpwdLogin:CButton=CButton.getSimpleBtn("??");
  562. btnpwdLogin.setOtherInfo({txtPwd:txtpwd});
  563. btnpwdLogin.addEventListener(MouseEvent.CLICK,function(e:MouseEvent):void{
  564. var obj:CTextInput=e.target.getOtherInfo().txtPwd;
  565. if(obj.text==DEBUG_PASSWORD){
  566. getLayer2_popup().removeTop();
  567. showDebugWin_msg();
  568. }else{
  569. alert(":(","debug pwd wrong!!!");
  570. }
  571. });
  572. ctem.appendSome([txtpwd,btnpwdLogin]);
  573. cwindpwd.getContainer().append(ctem);
  574. this.getLayer2_popup().popup(cwindpwd);
  575. }
  576. /**
  577. * ??debug??
  578. * @return
  579. *
  580. */
  581. public static function getDebugMsg():String{
  582. var strReturn:String="";
  583. for(var i:Number=0;i<DEBUG_MESSAGE.length;i++){
  584. strReturn+=DEBUG_MESSAGE[i]
  585. }
  586. return strReturn;
  587. }
  588. /**
  589. * ???????
  590. *
  591. */
  592. public function showDebugWin_msg():void{
  593. if(winDebug!=null) return;
  594. winDebug=new CWindowTextArea();
  595. winDebug.init("?????? :)___",true,false,false,this.getShowWidth()-100,this.getShowHeight()-100);
  596. winDebug.getPartWindow().getContainer().setBakColor(0xffffff,1);
  597. winDebug.htmlText=getDebugMsg();
  598. winDebug.getTextArea().getScroll().moveBarEnd();
  599. winDebug.setFunClose(closeWinDebug);
  600. this.getLayer2_popup().popup(winDebug);
  601. }
  602. //????????
  603. private function menu_debug_onselect(e:ContextMenuEvent):void{
  604. showDebugWin();
  605. }
  606. private function closeWinDebug(me:CWindowTextArea):void{
  607. this.getLayer2_popup().removeTop();
  608. winDebug=null;
  609. cwindpwd=null;
  610. }
  611. /**
  612. * ?????????????swf???. ?:???????lib.swf???(?????)??????cutload???????????????
  613. * ???????swf???????????????cutload.init(...)??????
  614. * @param swfname ??????? ,?????????".swf"
  615. * @param describe ?????????
  616. *
  617. */
  618. public function addLoadLibList(swfname:String,describe:String):void{
  619. arrLibList.push(swfname);
  620. arrLibList.push(describe);
  621. }
  622. //???????
  623. private function appLoadProgress(the:ProgressEvent):void {
  624. //trace("appLoadProgress:::"+(the.bytesLoaded/the.bytesTotal));
  625. if(loadBar!=null){
  626. loadBar.setValue(the.bytesLoaded/the.bytesTotal,"");
  627. }
  628. }
  629. /**
  630. * ??????????
  631. * @return
  632. *
  633. */
  634. public function get myURL():String{
  635. if(this.loaderInfo==null) return "";
  636. if(this.loaderInfo.url==null) return "";
  637. return this.loaderInfo.url;
  638. }
  639. /**
  640. * ??????????
  641. * @return
  642. *
  643. */
  644. public function get myURLPath():String{
  645. //return "http://balala.auldey.com/balala_addSoud/";
  646. var urlTem:String=myURL;
  647. if(urlTem=="") return "";
  648. return Fun.getFilePathStr(urlTem);
  649. }
  650. /**
  651. * ??????????????????????
  652. *
  653. */
  654. protected function LoadAppCompleteChekDo():void{
  655. if(loadBar!=null){
  656. if(loadBar.isLoadCompleteDo()){
  657. loadBar.loadComplete();
  658. }else{
  659. appLoadCompt_do();
  660. }
  661. }else{
  662. appLoadCompt_do();
  663. }
  664. }
  665. //???????
  666. private function appLoadCompt(e:Event):void{
  667. //
  668. //trace("???????");
  669. LoadAppCompleteChekDo();
  670. //
  671. }
  672. private function appLoadCompt_do():void{
  673. //trace("appLoadCompt_do");
  674. isAppLoadCmpt=true;
  675. root.loaderInfo.removeEventListener(ProgressEvent.PROGRESS,appLoadProgress);
  676. root.loaderInfo.removeEventListener(Event.COMPLETE,appLoadCompt);
  677. //???????????????????????????????????
  678. if(loadBar!=null){
  679. var loadBarBase:Sprite=loadBar as Sprite;
  680. if(loadBarBase!=null) if(loadBarBase.parent==this) this.removeChild(loadBarBase);
  681. loadBar=null;
  682. }
  683. if(this.totalFrames>1){
  684. play();
  685. if(whenAppLoadCompt!=null) whenAppLoadCompt();
  686. }
  687. appStart();
  688. }
  689. //???????????????????
  690. private var whenAppLoadCompt:Function=null
  691. /**
  692. * ???????????????????,?????????????????????????????????????????????????stop,???????????????????play???????????????????????????????
  693. * @param fun ????? ???function()
  694. *
  695. */
  696. public function setFunWhenAppLoadCompt(fun:Function):void{
  697. if(this.totalFrames==1){
  698. CutLoad.CutLoad.debug("CutLoad.setFunWhenAppLoadCompt(...) ??????????????????!",2);
  699. return;
  700. }
  701. whenAppLoadCompt=fun;
  702. }
  703. //?????????cutload?????????
  704. private function init():void{
  705. //
  706. init_noLoadLib();
  707. //??????????
  708. if(isNotUseUi){
  709. this.setLayerChildIndex_allTop();
  710. this.main();
  711. return;
  712. }
  713. //
  714. load(arrLibList[arrLibListIndex++],arrLibList[arrLibListIndex++], 1);
  715. }
  716. /**
  717. * ????????????
  718. * <p>?????flash???????lib.fla??????????????lib.swf,???????????flash???lib.swf???????</p>
  719. * <p>????????????????????????????????</p>
  720. *
  721. */
  722. private function init_noLoadLib():void{
  723. stage.addEventListener(Event.RESIZE,funResize);
  724. iniDiv()
  725. }
  726. /**
  727. * ??cutload????????????????????????
  728. * @return
  729. *
  730. */
  731. public function initOther():void{
  732. }
  733. /**
  734. * ????????????????????????????????????????????????????????????????
  735. *
  736. */
  737. public function main():void{
  738. }
  739. /**
  740. * ????????????lib.swf,ui.swf,????????????cutload?ui????????????????????????????????????? ????????????????????????ui????????????????????????????
  741. *
  742. */
  743. public function doNotLoadDefaultLib():void{
  744. isNotUseUi=true;
  745. //???????????????lib.swf,ui.swf?????????true
  746. isLoadMain=true;
  747. }
  748. private function updateBack():void{
  749. if(spBak!=null){
  750. this.swapChildren(updateBackForDepath,spBak);
  751. this.removeChild(spBak);
  752. }
  753. spBak=new CRender();
  754. spBak.mouseChildren=false;
  755. spBak.mouseEnabled=false;
  756. if(bakSaveConfig_obj==null){
  757. bakSaveConfig_type=0;
  758. bakSaveConfig_obj={color:0xff0000,alpha:0,isBitmap:false};
  759. }
  760. spBak.mouseEnabled=false;
  761. spBak.mouseChildren=false;
  762. spBak.init(bakSaveConfig_way,bakSaveConfig_type,bakSaveConfig_obj,this.getShowWidth(),this.getShowHeight());
  763. this.addChild(spBak);
  764. this.swapChildren(updateBackForDepath,spBak);
  765. }
  766. //??????
  767. private function removeCurrentModule():void{
  768. if(currentModule!=null){
  769. currentModule.killMe();
  770. if(currentModule.parent!=null) spFrameParent.removeChild(currentModule);
  771. currentModule=null;
  772. }
  773. }
  774. //?????
  775. protected function iniDiv():void{
  776. this.funResizeDo=null;
  777. //
  778. arrResize=new Array();
  779. //??
  780. updateBack()
  781. //???????
  782. removeCurrentModule();
  783. if(spFrameParent!=null) this.removeChild(spFrameParent);
  784. spFrameParent=new Sprite();
  785. this.addChild(spFrameParent);
  786. //
  787. //??
  788. if(containerAlign!=null) this.removeChild(containerAlign);
  789. containerAlign=new Container();
  790. containerAlign.init({w:this.getShowWidth(),h:this.getShowHeight(),lt_transition:config.CutLoad_addAlign_transition()});
  791. containerAlign.clrBak();
  792. this.addChild(containerAlign);
  793. //??
  794. if(spTop!=null) this.removeChild(spTop);
  795. spTop=new Sprite();
  796. this.addChild(spTop);
  797. //??
  798. if(Popup!=null) this.removeChild(Popup);
  799. if(PopupMode==0){
  800. Popup=new CPopup();
  801. }else{
  802. Popup=new CPopupSpring();
  803. }
  804. Popup.init(this.getShowWidth(),this.getShowHeight());
  805. this.addChild(Popup);
  806. //????????
  807. if(loadBar!=null) addLoadBar();
  808. //????,??????
  809. if(tipNoStageManagement!=null){
  810. tipNoStageManagement.clearAll();
  811. Fun.setTopDepath(tipNoStageManagement);
  812. }
  813. if(tipManagement!=null){
  814. tipManagement.clearAll();
  815. Fun.setTopDepath(tipManagement);
  816. }
  817. //??
  818. if(spWatermark.parent!=null) this.removeChild(spWatermark);
  819. this.addChild(spWatermark);
  820. }
  821. /**
  822. * ?????
  823. * @return
  824. *
  825. */
  826. public function resetLayer():void{
  827. this.iniDiv();
  828. }
  829. /**
  830. * ???????,?????????
  831. * <ol><b>????</b>
  832. * <li>????????0????,5????</li>
  833. * <li>????????????????Sprite,??????????,?????????addChild(..)????????????????</li>
  834. * <li>????????????????Sprite,?????????????????????????????????????????CutLoad?????getLayer?????????</li>
  835. * </ol>
  836. * <ol><b>??????</b>
  837. * <li>0:????????[???CTipManagement]</li>
  838. * <li>1:????????[???CTipManagement]</li>
  839. * <li>2:??[???CPopup]</li>
  840. * <li>3:??[???Sprite]</li>
  841. * <li>4:?????????[???Container]</li>
  842. * <li>5:??????[???Sprite]</li>
  843. * <li>6:????[???CRender]</li>
  844. * </ol>
  845. * @param index
  846. * @return
  847. *
  848. */
  849. public function getLayer(index:Number):Sprite{
  850. if(index<0||index>6) throw new Error("?????????:0~6");
  851. switch(index){
  852. case -1:
  853. return spWatermark;
  854. case 0:
  855. return tipManagement;
  856. break;
  857. case 1:
  858. return tipNoStageManagement;
  859. break;
  860. case 2:
  861. return Popup;
  862. break;
  863. case 3:
  864. return spTop;
  865. break;
  866. case 4:
  867. return containerAlign;
  868. break;
  869. case 5:
  870. return spFrameParent;
  871. break;
  872. default:
  873. return spBak;
  874. break;
  875. }
  876. }
  877. /**
  878. * ?cutload????????????
  879. * @return
  880. *
  881. */
  882. public function setLayerChildIndex_allTop():void{
  883. spBak_index=Fun.setTopDepath(this.getLayer6_bak());
  884. spFrameParent_index=Fun.setTopDepath(this.getLayer5_module());
  885. containerAlign_index=Fun.setTopDepath(this.getLayer4_align());
  886. spTop_index=Fun.setTopDepath(this.getLayer3_top());
  887. Popup_index=Fun.setTopDepath(this.getLayer2_popup());
  888. tipNoStageManagement_index=Fun.setTopDepath(this.getLayer1_tipNoStageManagement());
  889. tipManagement_index=Fun.setTopDepath(this.getLayer0_tipManagement());
  890. spWatermark_index=Fun.setTopDepath(spWatermark);
  891. }
  892. /**
  893. * ?????????
  894. * @param tipManagement_index
  895. * @param tipNoStageManagement_index
  896. * @param Popup_index
  897. * @param spTop_index
  898. * @param containerAlign_index
  899. * @param spFrameParent_index
  900. * @param spBak_index
  901. * @return
  902. *
  903. */
  904. public function setLayerChildIndex(tipManagement_index:Number,
  905. tipNoStageManagement_index:Number,
  906. Popup_index:Number,
  907. spTop_index:Number,
  908. containerAlign_index:Number,
  909. spFrameParent_index:Number,
  910. spBak_index:Number
  911. ):void{
  912. this.tipManagement_index=tipManagement_index;
  913. this.tipNoStageManagement_index=tipNoStageManagement_index;
  914. this.Popup_index=Popup_index;
  915. this.spTop_index=spTop_index;
  916. this.containerAlign_index=containerAlign_index;
  917. this.spFrameParent_index=spFrameParent_index;
  918. this.spBak_index=spBak_index;
  919. updateLayerChildIndex();
  920. //
  921. }
  922. //????
  923. private function updateLayerChildIndex():void{
  924. if(tipManagement_index==-1){
  925. tipManagement_index=this.getChildIndex(getLayer0_tipManagement());
  926. }else{
  927. this.setChildIndex(this.getLayer0_tipManagement(),tipManagement_index);
  928. }
  929. if(tipNoStageManagement_index==-1){
  930. tipNoStageManagement_index=this.getChildIndex(getLayer1_tipNoStageManagement());
  931. }else{
  932. this.setChildIndex(this.getLayer1_tipNoStageManagement(),tipNoStageManagement_index);
  933. }
  934. if(Popup_index==-1){
  935. Popup_index=this.getChildIndex(getLayer2_popup());
  936. }else{
  937. this.setChildIndex(this.getLayer2_popup(),Popup_index);
  938. }
  939. if(spTop_index==-1){
  940. spTop_index=this.getChildIndex(getLayer3_top());
  941. }else{
  942. this.setChildIndex(this.getLayer3_top(),spTop_index);
  943. }
  944. if(containerAlign_index==-1){
  945. containerAlign_index=this.getChildIndex(getLayer4_align());
  946. }else{
  947. this.setChildIndex(this.getLayer4_align(),containerAlign_index);
  948. }
  949. if(spFrameParent_index==-1){
  950. spFrameParent_index=this.getChildIndex(getLayer5_module());
  951. }else{
  952. this.setChildIndex(this.getLayer5_module(),spFrameParent_index);
  953. }
  954. if(spBak_index==-1){
  955. spBak_index=this.getChildIndex(getLayer6_bak());
  956. }else{
  957. this.setChildIndex(this.getLayer6_bak(),spBak_index);
  958. }
  959. }
  960. /**
  961. * ????
  962. * @param sp
  963. *
  964. */
  965. public function WatermarkAppend(sp:Sprite):void{
  966. this.spWatermark.addChild(sp);
  967. }
  968. /**
  969. * ???? ??
  970. * @param str ????
  971. * @param align ?????0?,1?,2?
  972. * @param color ??
  973. * @param size ???
  974. * @return
  975. *
  976. */
  977. public function WatermarkTxtAppend(str:String,align:uint=0,color:Number=0xff0000,size:Number=13):CTextField{
  978. var fmt:TextFormat=CTextField.getTextFormat(align,color,size);
  979. var txtTem:CTextField=CTextField.getSimpleTxt(str,fmt);
  980. WatermarkAppend(txtTem);
  981. return txtTem
  982. }
  983. /**
  984. * ??????
  985. *
  986. */
  987. public function WatermarkAppendClrAll():void{
  988. if(this.spWatermark==null) return;
  989. if(this.spWatermark.parent!=null){
  990. this.removeChild(this.spWatermark);
  991. this.spWatermark=null;
  992. }
  993. spWatermark=new Sprite();
  994. this.addChild(this.spWatermark);
  995. }
  996. /**
  997. * ???0,???CutLoad.getLayer(..)????????
  998. * @see CutLoad.getLayer()
  999. * @return
  1000. *
  1001. */
  1002. public function getLayer0_tipManagement():CTipManagement{
  1003. return tipManagement;
  1004. }
  1005. /**
  1006. * ???1,???CutLoad.getLayer(..)????????
  1007. * @return
  1008. *
  1009. */
  1010. public function getLayer1_tipNoStageManagement():CTipManagement{
  1011. //if(tipNoStageManagement==null) throw new Error("?????????!");
  1012. return tipNoStageManagement;
  1013. }
  1014. /**
  1015. * ???2,???CutLoad.getLayer(..)????????
  1016. * @return
  1017. *
  1018. */
  1019. public function getLayer2_popup():CPopup{
  1020. return Popup;
  1021. }
  1022. /**
  1023. * ???3,???CutLoad.getLayer(..)????????
  1024. * @return
  1025. *
  1026. */
  1027. public function getLayer3_top():Sprite{
  1028. return spTop;
  1029. }
  1030. /**
  1031. * ???4,???CutLoad.getLayer(..)????????
  1032. * @return
  1033. *
  1034. */
  1035. public function getLayer4_align():Container{
  1036. return containerAlign;
  1037. }
  1038. /**
  1039. * ???5,???CutLoad.getLayer(..)????????
  1040. * @return
  1041. *
  1042. */
  1043. public function getLayer5_module():Sprite{
  1044. return spFrameParent;
  1045. }
  1046. /**
  1047. * ???6,???CutLoad.getLayer(..)????????
  1048. * @return
  1049. *
  1050. */
  1051. public function getLayer6_bak():CRender{
  1052. return spBak;
  1053. }
  1054. /**
  1055. * ????? ??,??cutLoad.refreshLayout()????????????????????????.
  1056. * @param type 0?????????????1:??????????????,2:????? ?????0
  1057. *
  1058. */
  1059. public function refreshTip(type:Number=0):void{
  1060. if(type==0||type==2){
  1061. if(tipManagement!=null) this.tipManagement.update();
  1062. }
  1063. if(type==1||type==2){
  1064. if(tipNoStageManagement!=null) tipNoStageManagement.update();
  1065. }
  1066. }
  1067. /**
  1068. * ???????
  1069. * @param base ?????????
  1070. * @param content ?????
  1071. * @param tipWidth ?????
  1072. * @param isUpdateRect ??????????????????true,??????????????????????????????false,????????????true.
  1073. *
  1074. */
  1075. public function tip(base:Sprite,content:String,tipWidth:Number=0,isUpdateRect:Boolean=true):void{
  1076. iniTip()
  1077. tipManagement.add(base,content,tipWidth,isUpdateRect);
  1078. }
  1079. //??? ???????
  1080. private function iniTip():void{
  1081. if(tipManagement==null){
  1082. //??????
  1083. tipManagement=new CTipManagement();
  1084. this.addChild(tipManagement);
  1085. tipManagement.init();
  1086. }
  1087. }
  1088. /**
  1089. * ??? ?????? ???????
  1090. *
  1091. */
  1092. public function iniTipNoStageManagement():void{
  1093. if(tipNoStageManagement==null){
  1094. //??????
  1095. tipNoStageManagement=new CTipManagement();
  1096. this.addChild(tipNoStageManagement);
  1097. tipNoStageManagement.init();
  1098. tipNoStageManagement.stop();
  1099. }
  1100. }
  1101. /**
  1102. * ????????
  1103. * @return
  1104. *
  1105. */
  1106. public function getLoadBar():ILoadBar{
  1107. return loadBar
  1108. }
  1109. //???????????
  1110. private function addLoadBar():void{
  1111. //???????????
  1112. //trace("addLoadBar:LoadBarMainApp_x:"+LoadBarMainApp_x+" LoadBarMainApp_y:"+LoadBarMainApp_y);
  1113. if(LoadBarMainApp_x==NULLNO&&LoadBarMainApp_y==NULLNO){
  1114. this.addAlign((loadBar as Base));
  1115. }else{
  1116. this.getLayer4_align().appendXY(loadBar as Base,LoadBarMainApp_x,LoadBarMainApp_y);
  1117. }
  1118. }
  1119. //?????
  1120. private function createLoadBar(isAdd:Boolean=true):void{
  1121. if(loadBar!=null){
  1122. loadBar.showHide(true);
  1123. //trace("loadBar.showHide(true);");
  1124. return;
  1125. }
  1126. if(clone_loadBar==null){
  1127. //clone_loadBar=new Loadbar(200,20,0x000000,12,0xffffff,1,1,0xcccccc,1,0x000000,1)
  1128. clone_loadBar=new LoadbarForCutLoad();
  1129. }
  1130. loadBar=clone_loadBar.clone();
  1131. //??????????????
  1132. if(isAdd){
  1133. addLoadBar()
  1134. }
  1135. }
  1136. /**
  1137. * ????????
  1138. *
  1139. */
  1140. public function removeLoadBar():void{
  1141. //trace("removeLoadBar ");
  1142. loadBar.setValue(0,"");
  1143. loadBar.showHide(false);
  1144. }
  1145. /**
  1146. * ??????????
  1147. * @param newLoadbar ????????????????CutLoad.components.ILoadBar
  1148. * @param xxx ???????x???0?????????,?????CutLoad.CutLoad.NULLNO
  1149. * @param yyy ???????y???0?????????,?????CutLoad.CutLoad.NULLNO
  1150. *
  1151. */
  1152. public function setLoadBar(newLoadbar:ILoadBar,xxx:Number=0,yyy:Number=0):void{
  1153. if(!(newLoadbar is Base)) throw new Error("?????????Base???????ILoadBar??");
  1154. loadBarModule_x=xxx;
  1155. loadBarModule_y=yyy;
  1156. clone_loadBar=newLoadbar;
  1157. }
  1158. //
  1159. private var bakSaveConfig_type:uint=0;
  1160. private var bakSaveConfig_way:uint=0;
  1161. private var bakSaveConfig_obj:Object=null;
  1162. /**
  1163. * ??????? CutLoad.components.CRender.init(...) ??
  1164. * @param type
  1165. * @param config
  1166. *
  1167. */
  1168. public function setBak(way:uint,type:uint,config:Object):void{
  1169. bakSaveConfig_obj=config;
  1170. bakSaveConfig_type=type
  1171. bakSaveConfig_way=way;
  1172. updateBack();
  1173. }
  1174. /**
  1175. * ??????
  1176. * @param bakColor ???
  1177. * @param bakAlpha ?????
  1178. * @param isBitmap ???????????
  1179. *
  1180. */
  1181. public function setColorBak(bakColor:Number,bakAlpha:Number=1,isBitmap:Boolean=false):void{
  1182. setBak(0,0,{color:bakColor,alpha:bakAlpha,isBitmap:isBitmap});
  1183. }
  1184. /**
  1185. * ??
  1186. * @param fps
  1187. *
  1188. */
  1189. public function set fps(f:Number):void{
  1190. if(stage==null) return;
  1191. stage.frameRate=f;
  1192. }
  1193. /**
  1194. * ??
  1195. * @return
  1196. *
  1197. */
  1198. public function get fps():Number{
  1199. if(stage==null) return 0;
  1200. return stage.frameRate
  1201. }
  1202. //??-----------------------------------------------start------------------------------------------
  1203. private var loadLibCompelet:Function=null;
  1204. /**
  1205. * ?????? ,??????????????????????
  1206. * @param p_url SWF??,?????".swf"
  1207. * @param loadbarTalkYou ??????????
  1208. * @param loadLibCompelet ?????????,????????????????????????null.
  1209. *
  1210. */
  1211. public function loadLibSwf(p_url : String,loadbarTalkYou:String="",loadLibCompelet:Function=null):void{
  1212. if(loadLibCompelet==null) loadLibCompelet=function():void{};
  1213. this.loadLibCompelet=loadLibCompelet;
  1214. load(p_url,loadbarTalkYou,1);
  1215. }
  1216. //???????????????????????????----------------------------
  1217. private var forLoader_load:Loader=null;
  1218. private var forLoader_load_url:URLRequest=null;
  1219. private var forLoader_load_context:LoaderContext=null;
  1220. private var forLoader_load_i:Number=0;
  1221. private var forLoader_load_icount:Number=5;
  1222. //??????
  1223. private function reLoad():void{
  1224. forLoader_load_i++;
  1225. if(forLoader_load_i<=forLoader_load_icount){
  1226. if(forLoader_load!=null&&forLoader_load_url!=null&&forLoader_load_context!=null){
  1227. debug("????:"+forLoader_load_url+" ==> ?"+forLoader_load_i+"?",1)
  1228. forLoader_load.load(forLoader_load_url,forLoader_load_context);
  1229. }
  1230. }
  1231. if(forLoader_load_i==forLoader_load_icount){
  1232. forLoader_load_i=0;
  1233. forLoader_load=null;
  1234. forLoader_load_url=null;
  1235. forLoader_load_context=null;
  1236. }
  1237. }
  1238. /**
  1239. * ??????????????????????????????????????????????cutload?????????????????5????????????
  1240. * @param num
  1241. *
  1242. */
  1243. public function setReLoadTimes(num:Number):void{
  1244. forLoader_load_icount=num;
  1245. }
  1246. private var loadbarTalkYou:String="";
  1247. /**
  1248. * ??SWF
  1249. *
  1250. * @param p_url SWF??,?????".swf"
  1251. * @param p_url ??????????
  1252. * @param p_target ?????ApplicationDomain 1??,0??,2??
  1253. */
  1254. protected function load(p_url : String,loadbarTalkYou:String="", p_target:Number=0) : void
  1255. {
  1256. p_url=p_url+".swf";
  1257. if(VersionMyApp!==""){
  1258. p_url+="?"+VersionMyApp;
  1259. }
  1260. //trace("load....:::"+p_url)
  1261. debug("[load] "+loadbarTalkYou+"--->"+p_url,1);
  1262. nowLoadSwfName=p_url;
  1263. if(loadbarTalkYou=="") loadbarTalkYou="Load:"+p_url+" ";
  1264. this.loadbarTalkYou=loadbarTalkYou;
  1265. //???????
  1266. createLoadBar()
  1267. loadBar.setValue(0,loadbarTalkYou);
  1268. LoadBarModuleAppResize(this.getShowWidth(),this.getShowHeight(),loadBar);
  1269. this.update();
  1270. //
  1271. var loader:Loader = new Loader();
  1272. var context:LoaderContext = new LoaderContext();
  1273. switch (p_target)
  1274. {
  1275. case 0 :
  1276. context.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
  1277. break;
  1278. case 1 :
  1279. context.applicationDomain = ApplicationDomain.currentDomain;
  1280. break;
  1281. case 2 :
  1282. context.applicationDomain = new ApplicationDomain();
  1283. break;
  1284. default:
  1285. throw new Error("???????:1??,0??,2??");
  1286. break;
  1287. }
  1288. this.initLoadEvent(loader.contentLoaderInfo);
  1289. //
  1290. forLoader_load=loader;
  1291. forLoader_load_context=context;
  1292. forLoader_load_url=new URLRequest(p_url);
  1293. loader.load(forLoader_load_url, context);
  1294. }
  1295. //---------------------??????????----------------
  1296. private var LoadModuleSwf_doThisLater_endDo_swfName:String;
  1297. //?????????????????????????????????
  1298. private function LoadModuleSwf_doThisLater_endDo_fun():void{
  1299. LoadModuleSwf(LoadModuleSwf_doThisLater_endDo_swfName);
  1300. }
  1301. /**
  1302. * ?????????????????????????????????
  1303. * @param swfName
  1304. *
  1305. */
  1306. public function LoadModuleSwf_doThisLater(swfName:String):void{
  1307. //debug("LoadModuleSwf_doThisLater-->"+swfName);
  1308. if(this.currentModule==null){
  1309. LoadModuleSwf(swfName);
  1310. return;
  1311. }
  1312. swfName=swfName.toLocaleLowerCase();
  1313. if(swfName.indexOf(".swf")!=-1) throw new Error("???.swf");
  1314. if(swfName==this.currentModuleData.url) return;
  1315. LoadModuleSwf_doThisLater_endDo_swfName=swfName;
  1316. this.currentModule.leaveMovieStart(LoadModuleSwf_doThisLater_endDo_fun);
  1317. }
  1318. //
  1319. private var funLoadModuleSwfCompt:Function;
  1320. /**
  1321. * ?????????5?????????????CutLoad.getLayer()???
  1322. * @param swfName swf?????????".swf"
  1323. * @param describe ???? ?????????:"load:???.swf"
  1324. * @param p_target ????0,?????1??,0??,2??
  1325. * @param funLoadModuleSwfCompt ????????????
  1326. * @param isOptimizeMemory ??????,?????
  1327. * @return
  1328. *
  1329. */
  1330. public function LoadModuleSwf(swfName:String,describe:String="",p_target:Number=0,funLoadModuleSwfCompt:Function=null,isOptimizeMemory:Boolean=true):void{
  1331. debug("LoadModuleSwf -> :"+swfName);
  1332. swfName=swfName.toLocaleLowerCase()
  1333. if(swfName.indexOf(".swf")!=-1) throw new Error("???.swf");
  1334. //
  1335. if(currentModuleData!=null){
  1336. if(currentModuleData.url==swfName){
  1337. //??????????????
  1338. debug("LoadModuleSwf ????",2);
  1339. return;
  1340. }
  1341. }
  1342. if(funLoadModuleSwfCompt!=null) this.funLoadModuleSwfCompt=funLoadModuleSwfCompt;
  1343. //?????????????iniDiv()
  1344. //if(isLoadMain) iniDiv();
  1345. //????????
  1346. var indexTem:Number=moduleData.seachOne(swfName,ModuleData.URL)
  1347. if(indexTem==-1){
  1348. currentModuleData=new ModuleData(swfName);
  1349. //trace("LoadModuleSwf:"+currentModuleData);
  1350. moduleData.add(currentModuleData);
  1351. }else{
  1352. currentModuleData=moduleData.getOne(indexTem) as ModuleData;
  1353. }
  1354. removeCurrentModule();
  1355. //????
  1356. load(swfName,describe, p_target);
  1357. if(!isLoadMain) isLoadMain=true;
  1358. if(isOptimizeMemory) OptimizeMemory();
  1359. }
  1360. /**
  1361. * ???????????
  1362. * @return
  1363. *
  1364. */
  1365. public function delCurrentModuleSwf():void{
  1366. if(isLoadMain) iniDiv();
  1367. }
  1368. /**
  1369. * ???????????
  1370. * @return
  1371. *
  1372. */
  1373. public function getCurrentModule():ModuleBase{
  1374. if(this.currentModule==null) throw new Error("???????????");
  1375. return this.currentModule;
  1376. }
  1377. /**
  1378. * ???????????
  1379. * @param url ???,????:".swf"
  1380. * @return
  1381. *
  1382. */
  1383. public function ModuleDataGet(url:String):ModuleData{
  1384. if(url.indexOf(".swf")!=-1) throw new Error("???.swf");
  1385. var indexTem:Number=moduleData.seachOne(url,ModuleData.URL);
  1386. if(indexTem==-1){
  1387. throw new Error("?????????????????:"+url);
  1388. }
  1389. return (moduleData.getOne(indexTem) as ModuleData);
  1390. }
  1391. /**
  1392. * ?? ????????
  1393. * @param md ????
  1394. *
  1395. */
  1396. public function ModuleDataCreate(md:ModuleData):void{
  1397. if(ModuleDataHave(md)){
  1398. throw new Error("?????????????????????????,??ModuleDataCreate()???");
  1399. }
  1400. moduleData.add(md);
  1401. }
  1402. /**
  1403. * ?? ????????????
  1404. * @param md
  1405. * @return
  1406. *
  1407. */
  1408. public function ModuleDataHave(md:ModuleData):Boolean{
  1409. var indexTem:Number=moduleData.seachOne(md.url,ModuleData.URL);
  1410. if(indexTem!=-1){
  1411. return true;
  1412. }
  1413. return false;
  1414. }
  1415. /**
  1416. * ??????????
  1417. * @param swfname ??????".swf"
  1418. *
  1419. */
  1420. public function ModuleDataClear(swfname:String):void{
  1421. var indexTem:Number=moduleData.seachOne(swfname,ModuleData.URL,true);
  1422. }
  1423. /**
  1424. * @private
  1425. * ??????
  1426. *
  1427. * @param p_info ?????LoaderInfo
  1428. */
  1429. private function initLoadEvent(p_info:LoaderInfo) : void
  1430. {
  1431. p_info.addEventListener(ProgressEvent.PROGRESS, this.onProgress);
  1432. p_info.addEventListener(Event.COMPLETE, this.onComplete);
  1433. p_info.addEventListener(IOErrorEvent.IO_ERROR, this.onError);
  1434. p_info.addEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
  1435. }
  1436. /**
  1437. * @private
  1438. * ??????
  1439. *
  1440. * @param p_info ?????LoaderInfo
  1441. */
  1442. private function removeLoadEvent(p_info : LoaderInfo) : void
  1443. {
  1444. p_info.removeEventListener(Event.COMPLETE, this.onComplete);
  1445. p_info.removeEventListener(ProgressEvent.PROGRESS, this.onProgress);
  1446. p_info.removeEventListener(IOErrorEvent.IO_ERROR, this.onError);
  1447. p_info.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, this.onError);
  1448. }
  1449. /* ???? */
  1450. private function onComplete(p_e : Event) : void
  1451. {
  1452. if(isLoadedLib<2){
  1453. isLoadedLib++;
  1454. }
  1455. //
  1456. var info : LoaderInfo = p_e.currentTarget as LoaderInfo;
  1457. this.removeLoadEvent(info);
  1458. //??????
  1459. //this.removeLoadBar();
  1460. //trace("isLoadMain:::"+isLoadMain);
  1461. if(!isLoadMain){
  1462. //??????
  1463. debug("???????",1);
  1464. if(this.loadBar!=null){
  1465. if(this.loadBar.isLoadCompleteDo()) {
  1466. loadBar.setLoadCompleteDo(function():void{
  1467. removeLoadBar();
  1468. //????????,????????main
  1469. if(isLoadedLib==2) isLoadMain=true;
  1470. if(isLoadMain){
  1471. debug("???? main()",1);
  1472. removeLoadBar();
  1473. loadModuleComplete(2,info);
  1474. }else{
  1475. loadModuleComplete(1,info);
  1476. }
  1477. });
  1478. }else{
  1479. //???????????
  1480. removeLoadBar();
  1481. //????????,????????main
  1482. if(isLoadedLib==2) isLoadMain=true;
  1483. if(isLoadMain){
  1484. debug("???? main()",1);
  1485. removeLoadBar();
  1486. loadModuleComplete(2,info);
  1487. }else{
  1488. loadModuleComplete(1,info);
  1489. }
  1490. }
  1491. //
  1492. //
  1493. }
  1494. }else{
  1495. //??loadLibCompelet?null???????,???????????,
  1496. if(loadLibCompelet==null){
  1497. if(!(info.content is ModuleBase)){
  1498. throw new Error("?????swf?????CutLoad.ModuleBase!!");
  1499. }
  1500. //??????
  1501. //debug("???????",1);
  1502. if(this.loadBar!=null){
  1503. if(this.loadBar.isLoadCompleteDo()) {
  1504. loadBar.setLoadCompleteDo(function():void{
  1505. removeLoadBar();
  1506. loadModuleComplete(3,info);
  1507. });
  1508. }else{
  1509. //???????????
  1510. removeLoadBar();
  1511. loadModuleComplete(3,info);
  1512. }
  1513. }
  1514. }else{
  1515. //?????
  1516. //debug("?????????",1);
  1517. if(this.loadBar!=null){
  1518. if(this.loadBar.isLoadCompleteDo()) {
  1519. loadBar.setLoadCompleteDo(function():void{
  1520. removeLoadBar();
  1521. loadModuleComplete(4,info);
  1522. });
  1523. }else{
  1524. //???????????
  1525. removeLoadBar();
  1526. loadModuleComplete(4,info);
  1527. }
  1528. }
  1529. //
  1530. }
  1531. }
  1532. }
  1533. //???????????
  1534. private function loadModuleComplete(type:uint,info:LoaderInfo):void{
  1535. switch(type){
  1536. case 1:
  1537. //??????
  1538. load(arrLibList[arrLibListIndex++],arrLibList[arrLibListIndex++], 1)
  1539. break;
  1540. case 2:
  1541. //????
  1542. this.setLayerChildIndex_allTop();
  1543. this.main();
  1544. break;
  1545. case 3:
  1546. //??????
  1547. currentModule=info.content as ModuleBase;
  1548. debug("cutload ???????????",2);
  1549. currentModule.initData(this.currentModuleData);
  1550. spFrameParent.addChild(currentModule);
  1551. //????
  1552. this.stage.focus=currentModule;
  1553. funLoadModuleSwfCompt();
  1554. set_containerAlign_currentModule();
  1555. break;
  1556. case 4:
  1557. //???????????
  1558. try{
  1559. loadLibCompelet(info.content);
  1560. }catch(e:ArgumentError){
  1561. loadLibCompelet();
  1562. }
  1563. //???????????null
  1564. loadLibCompelet=null;
  1565. break;
  1566. }
  1567. }
  1568. private function onProgress(p_e:ProgressEvent) : void
  1569. {
  1570. //trace("onProgress");
  1571. if(loadBar!=null){
  1572. loadBar.setValue(p_e.bytesLoaded/p_e.bytesTotal,loadbarTalkYou);
  1573. }
  1574. }
  1575. private function onError(p_e : Event) : void
  1576. {
  1577. var strTem123:String="?? \""+nowLoadSwfName+"\"?? ???"
  1578. //if(!isNotUseUi) this.alert("??!",strTem123);
  1579. debug(strTem123,1)
  1580. reLoad()
  1581. //?????????????
  1582. }
  1583. //????---------------------------------------------------------------------------------------
  1584. /**
  1585. * ????????????????????
  1586. * @param base
  1587. * @param resizeWH ?????????????????0?????,1????,2????
  1588. *
  1589. */
  1590. public function addResize(base:Base,resizeWH:Number=0):void{
  1591. if(resizeWH!=0&&resizeWH!=1&&resizeWH!=1) throw new Error("???resizeWH?????????:0?????,1????,2????");
  1592. arrResize.push({base:base,t:resizeWH});
  1593. }
  1594. /**
  1595. * ??????????????????
  1596. * @param fun ??:function();
  1597. *
  1598. */
  1599. public function setFunResizeDo(fun:Function):void{
  1600. funResizeDo=fun;
  1601. }
  1602. private function funResize(e:Event):void{
  1603. LoadBarModuleAppResize(this.getShowWidth(),this.getShowHeight(),loadBar);
  1604. if(isAutoResizeWH) update();
  1605. }
  1606. /**
  1607. * ????????????????,CutLoad.setWH()
  1608. * @param isOk
  1609. *
  1610. */
  1611. public function set autoResizeWH(isOk:Boolean):void{
  1612. isAutoResizeWH=isOk;
  1613. }
  1614. /**
  1615. * ???????????,??????????????????
  1616. * @param minW ???
  1617. * @param minH ???
  1618. *
  1619. */
  1620. public function setResizeMinWH(minW:Number,minH:Number):void{
  1621. this.minStageWidth=minW;
  1622. this.minStageHeight=minH;
  1623. }
  1624. /**
  1625. * ??????????????????????
  1626. * @param maxW ???? ????0????????????????????
  1627. * @param maxH ???? ????0????????????????????
  1628. *
  1629. */
  1630. public function setResizeMaxWH(maxW:Number=0,maxH:Number=0):void{
  1631. this.maxStageWidth=maxW;
  1632. this.maxStageHeight=maxH;
  1633. }
  1634. //??currentModule?????containerAlign?????????????setResizeMaxWH ?????
  1635. private function set_containerAlign_currentModule():void{
  1636. if(this.currentModule!=null){
  1637. this.currentModule.x=containerAlign.x;
  1638. this.currentModule.y=containerAlign.y;
  1639. }
  1640. }
  1641. /**
  1642. * ?????????? ????????????????????????????
  1643. * @return
  1644. *
  1645. */
  1646. public function get resizeMinWidth():Number{
  1647. return minStageWidth
  1648. }
  1649. /**
  1650. * ?????????? ????????????????????????????
  1651. * @return
  1652. *
  1653. */
  1654. public function get resizeMinHeight():Number{
  1655. return minStageHeight
  1656. }
  1657. /**
  1658. * ????????????????????????????? ???????????????CutLoad.autoResizeWH=true/false??
  1659. * @param w
  1660. * @param h
  1661. *
  1662. */
  1663. public function setWH(w:Number=0, h:Number=0):void{
  1664. if(w<this.minStageWidth) w=this.minStageWidth;
  1665. if(h<this.minStageHeight) h=this.minStageHeight;
  1666. //???????????,???????????????
  1667. var containerAlign_w:Number=w;
  1668. var containerAlign_h:Number=h;
  1669. //trace("www:"+w+" this.maxStageWidth "+this.maxStageWidth);
  1670. //trace("hhh:"+h+" this.maxStageHeight "+this.maxStageHeight)
  1671. if(maxStageWidth>0){
  1672. if(w>this.maxStageWidth){
  1673. containerAlign_w=this.maxStageWidth;
  1674. containerAlign.x=(this.getShowWidth()-containerAlign_w)/2;
  1675. }else{
  1676. containerAlign.x=0;
  1677. }
  1678. }
  1679. if(maxStageHeight>0){
  1680. if(h>this.maxStageHeight){
  1681. containerAlign_h=this.maxStageHeight;
  1682. containerAlign.y=(this.getShowHeight()-containerAlign_h)/2
  1683. }else{
  1684. containerAlign.y=0;
  1685. }
  1686. }
  1687. //??????????
  1688. if(this.minStageWidth>0){
  1689. if(w<this.minStageWidth){
  1690. containerAlign_w=minStageWidth;
  1691. }
  1692. }
  1693. if(this.minStageHeight>0){
  1694. if(h<this.minStageHeight){
  1695. containerAlign_h=minStageHeight;
  1696. }
  1697. }
  1698. containerAlign.setWH(containerAlign_w,containerAlign_h);
  1699. //trace("containerAlign.setWH "+containerAlign_w+","+containerAlign_h);
  1700. set_containerAlign_currentModule();
  1701. //
  1702. //
  1703. //
  1704. spBak.setWH(w,h);
  1705. Popup.setWH(w,h);
  1706. //
  1707. var obj:Object;
  1708. var baseTem:Base;
  1709. for(var i:Number=0;i<arrResize.length;i++){
  1710. obj=arrResize[i];
  1711. baseTem=obj.base;
  1712. if(obj.t==1){
  1713. baseTem.setWH(w,baseTem.getShowWidth());
  1714. }else if(obj.t==2){
  1715. baseTem.setWH(baseTem.getShowWidth(),h);
  1716. }else{
  1717. baseTem.setWH(w,h);
  1718. }
  1719. }
  1720. //??
  1721. if(tipManagement!=null) this.tipManagement.update();
  1722. //
  1723. //
  1724. if(funResizeDo!=null){
  1725. funResizeDo();
  1726. }
  1727. if(currentModule!=null) currentModule.setWH(this.getShowWidth(),this.getShowHeight());
  1728. }
  1729. //????---------------------------------------------------------------------------------------
  1730. /**
  1731. * ??? ?
  1732. *
  1733. */
  1734. private function update():void{
  1735. setWH(getShowWidth(),getShowHeight());
  1736. }
  1737. /**
  1738. * ??? ?
  1739. * ???? update()
  1740. */
  1741. public function refreshLayout():void{
  1742. update();
  1743. }
  1744. /**
  1745. * ?????????,????:0??,1??,2??,3??,4??,5??,6??,7??,8??
  1746. * @param base ????????
  1747. * @param t ????:0??,1??,2??,3??,4??,5??,6??,7??,8??
  1748. *
  1749. */
  1750. public function addAlign(base:Base,t:Number=0):void{
  1751. containerAlign.append(base,true,{t:t});
  1752. }
  1753. /**
  1754. * ??????????
  1755. * @param b…

Large files files are truncated, but you can click here to view the full file