├── demo ├── .wing │ ├── launch.json │ ├── packConfig.json │ └── tasks.json ├── bin-debug │ ├── LoadingUI.js │ ├── LoadingUI.js.map │ ├── Main.js │ └── Main.js.map ├── egretProperties.json ├── favicon.ico ├── index.html ├── libs │ └── modules │ │ ├── egret │ │ ├── egret.d.ts │ │ ├── egret.js │ │ ├── egret.min.js │ │ ├── egret.native.js │ │ ├── egret.native.min.js │ │ ├── egret.web.js │ │ └── egret.web.min.js │ │ ├── game │ │ ├── game.d.ts │ │ ├── game.js │ │ └── game.min.js │ │ ├── res │ │ ├── res.d.ts │ │ ├── res.js │ │ └── res.min.js │ │ ├── socket │ │ ├── socket.d.ts │ │ ├── socket.js │ │ └── socket.min.js │ │ ├── starlingSwf │ │ ├── starlingSwf.d.ts │ │ ├── starlingSwf.js │ │ └── starlingSwf.min.js │ │ └── tween │ │ ├── tween.d.ts │ │ ├── tween.js │ │ └── tween.min.js ├── polyfill │ ├── promise.js │ └── promise.min.js ├── resource │ ├── assets │ │ ├── bg.jpg │ │ ├── egret_icon.png │ │ ├── test.json │ │ ├── test.png │ │ └── test_swf.json │ ├── config │ │ └── description.json │ └── default.res.json ├── src │ ├── LoadingUI.ts │ └── Main.ts ├── template │ └── runtime │ │ ├── native_loader.js │ │ ├── native_require.js │ │ └── runtime_loader.js ├── tsconfig.json └── wingProperties.json └── libsrc ├── bin └── starlingSwf │ ├── starlingSwf.d.ts │ ├── starlingSwf.js │ └── starlingSwf.min.js ├── libs ├── egret.d.ts ├── game.d.ts ├── res.d.ts ├── socket.d.ts └── tween.d.ts ├── package.json ├── src └── lzm │ ├── display │ ├── Alert.ts │ └── BasePanel.ts │ ├── starlingswf │ ├── Swf.ts │ ├── SwfAnalyzer.ts │ ├── SwfUpdateManager.ts │ ├── blendmode │ │ └── SwfBlendMode.ts │ └── display │ │ ├── ISwfAnimation.ts │ │ ├── SwfButton.ts │ │ ├── SwfMovieClip.ts │ │ └── SwfSprite.ts │ └── utils │ ├── HttpClient.ts │ └── JSONWebSocketClient.ts └── tsconfig.json /demo/.wing/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Wing 内置播放器调试", 6 | "type": "chrome", 7 | "request": "launch", 8 | "file": "index.html", 9 | //"url": "http://mysite.com/index.html", //使用外部服务器时,请注释掉 file, 改用 url, 并将 useBuildInServer 设置为 false 10 | "runtimeExecutable": "${execPath}", 11 | "sourceMaps": true, 12 | "webRoot": "${workspaceRoot}", 13 | "preLaunchTask":"build", 14 | "port":5528 15 | }, 16 | { 17 | "name": "使用本机 Chrome 调试", 18 | "type": "chrome", 19 | "request": "launch", 20 | "file": "index.html", 21 | //"url": "http://mysite.com/index.html", //使用外部服务器时,请注释掉 file, 改用 url, 并将 useBuildInServer 设置为 false 22 | "runtimeExecutable": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome", // 改成您的 Chrome 安装路径 23 | "sourceMaps": true, 24 | "webRoot": "${workspaceRoot}", 25 | "preLaunchTask":"build", 26 | "userDataDir":"${tmpdir}", 27 | "port":5528 28 | }, 29 | { 30 | "name": "附加到 Chrome 进程", 31 | "type": "chrome", 32 | "request": "attach", 33 | "port": 9222, 34 | "webRoot": "${workspaceRoot}" 35 | } 36 | ] 37 | } -------------------------------------------------------------------------------- /demo/.wing/packConfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "maxImageWidth": 1024, 3 | "maxImageHeight": 1024, 4 | "defaultResPath": "/Users/zmliu1/Downloads/TestEgret/resource/default.res.json", 5 | "packGroups": { 6 | "preload": true 7 | } 8 | } -------------------------------------------------------------------------------- /demo/.wing/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "egret", 4 | "isShellCommand": true, 5 | "tasks": [ 6 | { 7 | "taskName": "build", 8 | "showOutput": "always", 9 | "args": [ 10 | "build", 11 | "-sourcemap" 12 | ], 13 | "problemMatcher": "$tsc" 14 | }, 15 | { 16 | "taskName": "clean", 17 | "showOutput": "always", 18 | "args": [ 19 | "build", 20 | "-e" 21 | ], 22 | "problemMatcher": "$tsc" 23 | }, 24 | { 25 | "taskName": "publish", 26 | "showOutput": "always", 27 | "args": [ 28 | "publish" 29 | ], 30 | "problemMatcher": "$tsc" 31 | } 32 | ] 33 | } -------------------------------------------------------------------------------- /demo/bin-debug/LoadingUI.js: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2014-present, Egret Technology. 4 | // All rights reserved. 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // * Neither the name of the Egret nor the 14 | // names of its contributors may be used to endorse or promote products 15 | // derived from this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 | // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, 23 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | ////////////////////////////////////////////////////////////////////////////////////// 29 | var __reflect = (this && this.__reflect) || function (p, c, t) { 30 | p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; 31 | }; 32 | var __extends = (this && this.__extends) || function (d, b) { 33 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; 34 | function __() { this.constructor = d; } 35 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 36 | }; 37 | var LoadingUI = (function (_super) { 38 | __extends(LoadingUI, _super); 39 | function LoadingUI() { 40 | return _super.call(this) || this; 41 | } 42 | LoadingUI.prototype.createView = function () { 43 | egret.log(this.stage); 44 | this.textField = new egret.TextField(); 45 | this.addChild(this.textField); 46 | this.textField.width = 480; 47 | this.textField.height = 100; 48 | this.textField.anchorOffsetX = 240; 49 | this.textField.anchorOffsetY = 50; 50 | this.textField.textAlign = "center"; 51 | egret.log(this.stage.stageWidth); 52 | this.textField.x = this.stage.stageWidth / 2; // - this.textField.width / 2; 53 | this.textField.y = this.stage.stageHeight / 2; // - this.textField.height / 2; 54 | }; 55 | LoadingUI.prototype.setProgress = function (current, total) { 56 | this.textField.text = "Loading..." + current + "/" + total; 57 | }; 58 | return LoadingUI; 59 | }(egret.Sprite)); 60 | __reflect(LoadingUI.prototype, "LoadingUI"); 61 | //# sourceMappingURL=LoadingUI.js.map -------------------------------------------------------------------------------- /demo/bin-debug/LoadingUI.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"LoadingUI.js","sourceRoot":"","sources":["../src/LoadingUI.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,EAAE;AACF,iDAAiD;AACjD,wBAAwB;AACxB,sEAAsE;AACtE,+EAA+E;AAC/E,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,8CAA8C;AAC9C,6EAA6E;AAC7E,8EAA8E;AAC9E,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,gFAAgF;AAChF,sDAAsD;AACtD,EAAE;AACF,sFAAsF;;;;;;;;;AAEtF;IAAwB,6BAAY;IAEhC;eACI,iBAAO;IACX,CAAC;IAIM,8BAAU,GAAjB;QACI,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,IAAI,CAAC,SAAS,GAAG,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9B,IAAI,CAAC,SAAS,CAAC,KAAK,GAAG,GAAG,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC;QAC5B,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,GAAG,CAAC;QACnC,IAAI,CAAC,SAAS,CAAC,aAAa,GAAG,EAAE,CAAC;QAClC,IAAI,CAAC,SAAS,CAAC,SAAS,GAAG,QAAQ,CAAC;QACpC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACjC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC,CAAA,8BAA8B;QAC3E,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,CAAA,+BAA+B;IACjF,CAAC;IAEM,+BAAW,GAAlB,UAAmB,OAAc,EAAE,KAAY;QAC3C,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,eAAa,OAAO,SAAI,KAAO,CAAC;IAC1D,CAAC;IACL,gBAAC;AAAD,CAAC,AAzBD,CAAwB,KAAK,CAAC,MAAM,GAyBnC;AAzBK,UAAA,SAAS,wBAyBd,CAAA"} -------------------------------------------------------------------------------- /demo/bin-debug/Main.js: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2014-present, Egret Technology. 4 | // All rights reserved. 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // * Neither the name of the Egret nor the 14 | // names of its contributors may be used to endorse or promote products 15 | // derived from this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 | // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, 23 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | ////////////////////////////////////////////////////////////////////////////////////// 29 | var __reflect = (this && this.__reflect) || function (p, c, t) { 30 | p.__class__ = c, t ? t.push(c) : t = [c], p.__types__ = p.__types__ ? t.concat(p.__types__) : t; 31 | }; 32 | var __extends = (this && this.__extends) || function (d, b) { 33 | for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; 34 | function __() { this.constructor = d; } 35 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 36 | }; 37 | var Main = (function (_super) { 38 | __extends(Main, _super); 39 | function Main() { 40 | var _this = _super.call(this) || this; 41 | _this.addEventListener(egret.Event.ADDED_TO_STAGE, _this.onAddToStage, _this); 42 | return _this; 43 | } 44 | Main.prototype.onAddToStage = function (event) { 45 | //设置加载进度界面 46 | //Config to load process interface 47 | this.loadingView = new LoadingUI(); 48 | this.stage.addChild(this.loadingView); 49 | this.loadingView.createView(); 50 | //初始化Resource资源加载库 51 | //initiate Resource loading library 52 | RES.registerAnalyzer("swf", starlingswf.SwfAnalyzer); 53 | RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); 54 | RES.loadConfig("resource/default.res.json", "resource/"); 55 | }; 56 | /** 57 | * 配置文件加载完成,开始预加载preload资源组。 58 | * configuration file loading is completed, start to pre-load the preload resource group 59 | */ 60 | Main.prototype.onConfigComplete = function (event) { 61 | RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); 62 | RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); 63 | RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this); 64 | RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); 65 | RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onItemLoadError, this); 66 | RES.loadGroup("preload"); 67 | }; 68 | /** 69 | * preload资源组加载完成 70 | * Preload resource group is loaded 71 | */ 72 | Main.prototype.onResourceLoadComplete = function (event) { 73 | if (event.groupName == "preload") { 74 | this.stage.removeChild(this.loadingView); 75 | RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); 76 | RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this); 77 | RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); 78 | RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onItemLoadError, this); 79 | this.createGameScene(); 80 | } 81 | }; 82 | /** 83 | * 资源组加载出错 84 | * The resource group loading failed 85 | */ 86 | Main.prototype.onItemLoadError = function (event) { 87 | console.warn("Url:" + event.resItem.url + " has failed to load"); 88 | }; 89 | /** 90 | * 资源组加载出错 91 | * The resource group loading failed 92 | */ 93 | Main.prototype.onResourceLoadError = function (event) { 94 | //TODO 95 | console.warn("Group:" + event.groupName + " has failed to load"); 96 | //忽略加载失败的项目 97 | //Ignore the loading failed projects 98 | this.onResourceLoadComplete(event); 99 | }; 100 | /** 101 | * preload资源组加载进度 102 | * Loading process of preload resource group 103 | */ 104 | Main.prototype.onResourceProgress = function (event) { 105 | if (event.groupName == "preload") { 106 | this.loadingView.setProgress(event.itemsLoaded, event.itemsTotal); 107 | } 108 | }; 109 | /** 110 | * 创建游戏场景 111 | * Create a game scene 112 | */ 113 | Main.prototype.createGameScene = function () { 114 | var swfData = RES.getRes("test_swf"); 115 | // this.swf = new starlingswf.Swf(swfData,this.stage.frameRate); 116 | this.swf = RES.getRes("test_swf"); 117 | this.swf.swfUpdateManager.setFps(this.stage.frameRate); 118 | this.test1(); 119 | // this.testAlert(); 120 | // this.testSocket(); 121 | // lzm.HttpClient.send("http://192.168.2.188/aptana/rings_server/test.php",{'a':123,"b":321},(data:string)=>{ 122 | // egret.log(data); 123 | // },null,'post'); 124 | }; 125 | /** 126 | * Sprite测试 127 | * */ 128 | Main.prototype.test1 = function () { 129 | var sprite = this.swf.createSprite("spr_1"); 130 | this.addChild(sprite); 131 | }; 132 | /** 133 | * MovieClip测试 134 | * */ 135 | Main.prototype.test2 = function () { 136 | var mcNames = ["mc_lajiao", "mc_test1", "mc_Tain", "mc_Zombie_balloon", "mc_Zombie_dolphinrider", "mc_Zombie_gargantuar", "mc_Zombie_imp", "mc_Zombie_jackbox", "mc_Zombie_ladder", "mc_Zombie_polevaulter"]; 137 | for (var i = 0; i < 50; i++) { 138 | var mcName = mcNames[Math.floor(Math.random() * mcNames.length)]; 139 | var mc = this.swf.createMovie(mcName); 140 | mc.x = Math.random() * 480; 141 | mc.y = Math.random() * 320; 142 | this.addChild(mc); 143 | } 144 | }; 145 | /** 146 | * 动画事件测试 147 | * */ 148 | Main.prototype.test3 = function () { 149 | var mc = this.swf.createMovie("mc_Tain"); 150 | mc.x = 480 / 2; 151 | mc.y = 320 / 2; 152 | mc.addEventListener(egret.Event.COMPLETE, this.mcComplete, mc); 153 | mc.gotoAndPlay("walk"); 154 | this.addChild(mc); 155 | }; 156 | Main.prototype.mcComplete = function (e) { 157 | console.log("mcComplete"); 158 | }; 159 | /** 160 | * 帧事件测试 161 | * */ 162 | Main.prototype.test4 = function () { 163 | var mc = this.swf.createMovie("mc_frame_event"); 164 | mc.addEventListener("@out", this.frameEventOut, mc); 165 | mc.addEventListener("@in", this.frameEventIn, mc); 166 | this.addChild(mc); 167 | }; 168 | Main.prototype.frameEventOut = function (e) { 169 | egret.log("@out"); 170 | }; 171 | Main.prototype.frameEventIn = function (e) { 172 | egret.log("@in"); 173 | }; 174 | /** 175 | * blendMode 176 | * */ 177 | Main.prototype.test5 = function () { 178 | var spr = this.swf.createSprite("spr_blendmode"); 179 | this.addChild(spr); 180 | }; 181 | Main.prototype.testBtn = function () { 182 | var btn = this.swf.createButton("btn_test1"); 183 | this.addChild(btn); 184 | btn.addEventListener(starlingswf.SwfButton.onClick, function (evt) { 185 | egret.log("onClick"); 186 | }, this); 187 | }; 188 | Main.prototype.testSocket = function () { 189 | var socket = new lzm.JSONWebSocketClient("127.0.0.1", 8501); 190 | socket.onConnectCallBack = function () { 191 | egret.log("链接成功"); 192 | socket.sendData({ "a": "a", "b": "b" }); 193 | }; 194 | socket.onIOErrorCallBack = function () { 195 | egret.log("链接失败"); 196 | }; 197 | socket.onDataCallBack = function (data) { 198 | egret.log(data); 199 | }; 200 | socket.onCloseCallBack = function () { 201 | egret.log("链接关闭"); 202 | }; 203 | socket.connect(); 204 | }; 205 | Main.prototype.testAlert = function () { 206 | lzm.Alert.init(this.stage); 207 | var shape = new egret.Shape(); 208 | shape.graphics.beginFill(0xff00ff); 209 | shape.graphics.drawRect(0, 0, 100, 100); 210 | shape.graphics.endFill(); 211 | lzm.Alert.alert(shape); 212 | }; 213 | return Main; 214 | }(egret.DisplayObjectContainer)); 215 | __reflect(Main.prototype, "Main"); 216 | //# sourceMappingURL=Main.js.map -------------------------------------------------------------------------------- /demo/bin-debug/Main.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"Main.js","sourceRoot":"","sources":["../src/Main.ts"],"names":[],"mappings":"AAAA,sFAAsF;AACtF,EAAE;AACF,iDAAiD;AACjD,wBAAwB;AACxB,sEAAsE;AACtE,+EAA+E;AAC/E,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,0EAA0E;AAC1E,4EAA4E;AAC5E,6EAA6E;AAC7E,8CAA8C;AAC9C,6EAA6E;AAC7E,8EAA8E;AAC9E,EAAE;AACF,+EAA+E;AAC/E,gFAAgF;AAChF,2EAA2E;AAC3E,gFAAgF;AAChF,gFAAgF;AAChF,8EAA8E;AAC9E,6EAA6E;AAC7E,wEAAwE;AACxE,gFAAgF;AAChF,sDAAsD;AACtD,EAAE;AACF,sFAAsF;;;;;;;;;AAEtF;IAAmB,wBAA4B;IAQ3C;QAAA,YACI,iBAAO,SAEV;QADG,KAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,cAAc,EAAE,KAAI,CAAC,YAAY,EAAE,KAAI,CAAC,CAAC;;IAC/E,CAAC;IAEO,2BAAY,GAApB,UAAqB,KAAiB;QAClC,UAAU;QACV,kCAAkC;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACtC,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,CAAC;QAE9B,kBAAkB;QAClB,mCAAmC;QACnC,GAAG,CAAC,gBAAgB,CAAC,KAAK,EAAC,WAAW,CAAC,WAAW,CAAC,CAAC;QACpD,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACrF,GAAG,CAAC,UAAU,CAAC,2BAA2B,EAAE,WAAW,CAAC,CAAC;IAC7D,CAAC;IAED;;;OAGG;IACK,+BAAgB,GAAxB,UAAyB,KAAuB;QAC5C,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAC;QACxF,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;QAC1F,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;QACzF,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;QACtF,GAAG,CAAC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;QACpF,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED;;;OAGG;IACK,qCAAsB,GAA9B,UAA+B,KAAuB;QAClD,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC;YAC/B,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzC,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,sBAAsB,EAAE,IAAI,CAAC,CAAC;YAC7F,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,gBAAgB,EAAE,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;YAC5F,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;YACzF,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,aAAa,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC;YACvF,IAAI,CAAC,eAAe,EAAE,CAAC;QAC3B,CAAC;IACL,CAAC;IAED;;;OAGG;IACK,8BAAe,GAAvB,UAAwB,KAAuB;QAC3C,OAAO,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,GAAG,qBAAqB,CAAC,CAAC;IACrE,CAAC;IAED;;;OAGG;IACK,kCAAmB,GAA3B,UAA4B,KAAuB;QAC/C,MAAM;QACN,OAAO,CAAC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,GAAG,qBAAqB,CAAC,CAAC;QACjE,WAAW;QACX,oCAAoC;QACpC,IAAI,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IAED;;;OAGG;IACK,iCAAkB,GAA1B,UAA2B,KAAuB;QAC9C,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,IAAI,SAAS,CAAC,CAAC,CAAC;YAC/B,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;QACtE,CAAC;IACL,CAAC;IAMD;;;OAGG;IACK,8BAAe,GAAvB;QACI,IAAI,OAAO,GAAU,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAC5C,gEAAgE;QAChE,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QAClC,IAAI,CAAC,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACvD,IAAI,CAAC,KAAK,EAAE,CAAC;QAEb,oBAAoB;QAEpB,qBAAqB;QAErB,6GAA6G;QAC7G,uBAAuB;QACvB,kBAAkB;IACtB,CAAC;IAID;;SAEK;IACG,oBAAK,GAAb;QACI,IAAI,MAAM,GAAyB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAClE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED;;SAEK;IACG,oBAAK,GAAb;QAEI,IAAI,OAAO,GAAY,CAAC,WAAW,EAAC,UAAU,EAAC,SAAS,EAAC,mBAAmB,EAAC,wBAAwB,EAAC,sBAAsB,EAAC,eAAe,EAAC,mBAAmB,EAAC,kBAAkB,EAAC,uBAAuB,CAAC,CAAC;QAC7M,GAAG,CAAA,CAAC,IAAI,CAAC,GAAU,CAAC,EAAG,CAAC,GAAG,EAAE,EAAG,CAAC,EAAE,EAAC,CAAC;YACjC,IAAI,MAAM,GAAU,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;YACxE,IAAI,EAAE,GAA4B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;YAC/D,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;YAC3B,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACtB,CAAC;IAEL,CAAC;IAED;;SAEK;IACG,oBAAK,GAAb;QACI,IAAI,EAAE,GAA4B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;QAClE,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QACf,EAAE,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC;QACf,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAC,IAAI,CAAC,UAAU,EAAC,EAAE,CAAC,CAAC;QAC7D,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAEO,yBAAU,GAAlB,UAAmB,CAAa;QAC5B,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9B,CAAC;IAED;;SAEK;IACG,oBAAK,GAAb;QACI,IAAI,EAAE,GAA4B,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;QACzE,EAAE,CAAC,gBAAgB,CAAC,MAAM,EAAC,IAAI,CAAC,aAAa,EAAC,EAAE,CAAC,CAAC;QAClD,EAAE,CAAC,gBAAgB,CAAC,KAAK,EAAC,IAAI,CAAC,YAAY,EAAC,EAAE,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAEO,4BAAa,GAArB,UAAsB,CAAa;QAC/B,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,CAAC;IAEO,2BAAY,GAApB,UAAqB,CAAa;QAC9B,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED;;SAEK;IACG,oBAAK,GAAb;QACI,IAAI,GAAG,GAAyB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,eAAe,CAAC,CAAC;QACvE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACvB,CAAC;IAEO,sBAAO,GAAf;QACI,IAAI,GAAG,GAAyB,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC;QACnE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QAEnB,GAAG,CAAC,gBAAgB,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,EAAC,UAAE,GAAe;YAChE,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACzB,CAAC,EAAC,IAAI,CAAC,CAAA;IACX,CAAC;IAEO,yBAAU,GAAlB;QACI,IAAI,MAAM,GAA2B,IAAI,GAAG,CAAC,mBAAmB,CAAC,WAAW,EAAC,IAAI,CAAC,CAAC;QAEnF,MAAM,CAAC,iBAAiB,GAAG;YACvB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAClB,MAAM,CAAC,QAAQ,CAAC,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,GAAG,EAAC,CAAC,CAAC;QACvC,CAAC,CAAA;QAED,MAAM,CAAC,iBAAiB,GAAG;YACtB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAA;QAED,MAAM,CAAC,cAAc,GAAG,UAAC,IAAW;YAChC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACpB,CAAC,CAAA;QAED,MAAM,CAAC,eAAe,GAAG;YACpB,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC,CAAA;QAED,MAAM,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;IAEO,wBAAS,GAAjB;QACI,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAE3B,IAAI,KAAK,GAAe,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAC1C,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACnC,KAAK,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,EAAC,CAAC,EAAC,GAAG,EAAC,GAAG,CAAC,CAAC;QACrC,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEzB,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE3B,CAAC;IACL,WAAC;AAAD,CAAC,AA5ND,CAAmB,KAAK,CAAC,sBAAsB,GA4N9C;AA5NK,UAAA,IAAI,mBA4NT,CAAA"} -------------------------------------------------------------------------------- /demo/egretProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "native": { 3 | "path_ignore": [] 4 | }, 5 | "publish": { 6 | "web": 0, 7 | "native": 1, 8 | "path": "bin-release" 9 | }, 10 | "egret_version": "4.0.1", 11 | "modules": [ 12 | { 13 | "name": "egret" 14 | }, 15 | { 16 | "name": "game" 17 | }, 18 | { 19 | "name": "tween" 20 | }, 21 | { 22 | "name": "res" 23 | }, 24 | { 25 | "name": "socket" 26 | }, 27 | { 28 | "name": "starlingSwf", 29 | "path": "../libsrc" 30 | } 31 | ] 32 | } -------------------------------------------------------------------------------- /demo/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zmLiu/StarlingSwf-Egret/d675b22a36a5417b2d307c5ccb9bef35d2f0c0af/demo/favicon.ico -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Egret 6 | 7 | 8 | 9 | 10 | 11 | 12 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 |
57 |
58 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /demo/libs/modules/res/res.min.js: -------------------------------------------------------------------------------- 1 | var __reflect=this&&this.__reflect||function(e,t,r){e.__class__=t,r?r.push(t):r=[t],e.__types__=e.__types__?r.concat(e.__types__):r},__extends=this&&this.__extends||function(e,t){function r(){this.constructor=e}for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i]);e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)},RES;!function(e){var t=function(t){function r(){var r=t.call(this)||this;return r.resourceConfig=null,r.resourceConfig=e.configInstance,r}return __extends(r,t),r.prototype.addSubkey=function(e,t){this.resourceConfig.addSubkey(e,t)},r.prototype.loadFile=function(e,t,r){},r.prototype.getRes=function(e){},r.prototype.destroyRes=function(e){return!1},r.getStringPrefix=function(e){if(!e)return"";var t=e.indexOf(".");return-1!=t?e.substring(0,t):""},r.getStringTail=function(e){if(!e)return"";var t=e.indexOf(".");return-1!=t?e.substring(t+1):""},r}(egret.HashObject);e.AnalyzerBase=t,__reflect(t.prototype,"RES.AnalyzerBase")}(RES||(RES={}));var RES;!function(e){var t=function(t){function r(){var e=t.call(this)||this;return e.fileDic={},e.resItemDic=[],e._dataFormat=egret.HttpResponseType.ARRAY_BUFFER,e.recycler=[],e}return __extends(r,t),r.prototype.loadFile=function(t,r,i){if(this.fileDic[t.name])return void r.call(i,t);var n=this.getRequest();this.resItemDic[n.hashCode]={item:t,func:r,thisObject:i},n.open(e.$getVirtualUrl(t.url)),n.send()},r.prototype.getRequest=function(){var e=this.recycler.pop();return e||(e=new egret.HttpRequest,e.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),e.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this)),e.responseType=this._dataFormat,e},r.prototype.onLoadFinish=function(e){var t=e.target,r=this.resItemDic[t.hashCode];delete this.resItemDic[t.hashCode];var i=r.item,n=r.func;i.loaded=e.type==egret.Event.COMPLETE,i.loaded&&this.analyzeData(i,t.response),this.recycler.push(t),n.call(r.thisObject,i)},r.prototype.analyzeData=function(e,t){var r=e.name;this.fileDic[r]||""!=t&&!t||(this.fileDic[r]=t)},r.prototype.getRes=function(e){return this.fileDic[e]},r.prototype.hasRes=function(e){var t=this.getRes(e);return null!=t},r.prototype.destroyRes=function(e){return this.fileDic[e]?(this.onResourceDestroy(this.fileDic[e]),delete this.fileDic[e],!0):!1},r.prototype.onResourceDestroy=function(e){},r}(e.AnalyzerBase);e.BinAnalyzer=t,__reflect(t.prototype,"RES.BinAnalyzer")}(RES||(RES={}));var RES;!function(e){var t=function(){function e(e,t,r){this.groupName="",this.data=null,this._loaded=!1,this.name=e,this.url=t,this.type=r}return Object.defineProperty(e.prototype,"loaded",{get:function(){return this.data?this.data.loaded:this._loaded},set:function(e){this.data&&(this.data.loaded=e),this._loaded=e},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return'[ResourceItem name="'+this.name+'" url="'+this.url+'" type="'+this.type+'"]'},e}();t.TYPE_XML="xml",t.TYPE_IMAGE="image",t.TYPE_BIN="bin",t.TYPE_TEXT="text",t.TYPE_JSON="json",t.TYPE_SHEET="sheet",t.TYPE_FONT="font",t.TYPE_SOUND="sound",e.ResourceItem=t,__reflect(t.prototype,"RES.ResourceItem")}(RES||(RES={}));var RES;!function(e){var t=function(t){function r(){var e=t.call(this)||this;return e.sheetMap={},e.textureMap={},e.recyclerIamge=[],e._dataFormat=egret.HttpResponseType.TEXT,e}return __extends(r,t),r.prototype.getRes=function(t){var r=this.fileDic[t];if(r||(r=this.textureMap[t]),!r){var i=e.AnalyzerBase.getStringPrefix(t);if(r=this.fileDic[i]){var n=e.AnalyzerBase.getStringTail(t);r=r.getTexture(n)}}return r},r.prototype.onLoadFinish=function(e){var t=e.target,r=this.resItemDic[t.$hashCode];delete this.resItemDic[t.hashCode];var i=r.item,n=r.func;if(i.loaded=e.type==egret.Event.COMPLETE,i.loaded)if(t instanceof egret.HttpRequest){i.loaded=!1;var o=this.analyzeConfig(i,t.response);if(o)return this.loadImage(o,r),void this.recycler.push(t)}else{var s=new egret.Texture;s._setBitmapData(t.data),this.analyzeBitmap(i,s)}t instanceof egret.HttpRequest?this.recycler.push(t):this.recyclerIamge.push(t),n.call(r.thisObject,i)},r.prototype.analyzeConfig=function(e,t){var r,i=e.name,n="";try{var o=t;r=JSON.parse(o)}catch(s){egret.$warn(1017,e.url,t)}return r&&(this.sheetMap[i]=r,n=this.getRelativePath(e.url,r.file)),n},r.prototype.analyzeBitmap=function(e,t){var r=e.name;if(!this.fileDic[r]&&t){var i=this.sheetMap[r];delete this.sheetMap[r];var n=e.data&&e.data.subkeys?"":r,o=this.parseSpriteSheet(t,i,n);this.fileDic[r]=o}},r.prototype.getRelativePath=function(e,t){e=e.split("\\").join("/");var r=e.match(/#.*|\?.*/),i="";r&&(i=r[0]);var n=e.lastIndexOf("/");return e=-1!=n?e.substring(0,n+1)+t:t,e+i},r.prototype.parseSpriteSheet=function(e,t,r){var i=t.frames;if(!i)return null;var n=new egret.SpriteSheet(e),o=this.textureMap;for(var s in i){var a=i[s],u=n.createTexture(s,a.x,a.y,a.w,a.h,a.offX,a.offY,a.sourceW,a.sourceH);if(a.scale9grid){var c=a.scale9grid,l=c.split(",");u.scale9Grid=new egret.Rectangle(parseInt(l[0]),parseInt(l[1]),parseInt(l[2]),parseInt(l[3]))}null==o[s]&&(o[s]=u,r&&this.addSubkey(s,r))}return n},r.prototype.destroyRes=function(e){var t=this.fileDic[e];if(t){delete this.fileDic[e];var r=void 0;for(var i in t._textureMap)null==r&&(r=t._textureMap[i],this.onResourceDestroy(r),r=null),delete this.textureMap[i];return t.dispose&&t.dispose(),!0}return!1},r.prototype.loadImage=function(t,r){var i=this.getImageLoader();this.resItemDic[i.hashCode]=r,i.load(e.$getVirtualUrl(t))},r.prototype.getImageLoader=function(){var e=this.recyclerIamge.pop();return e||(e=new egret.ImageLoader,e.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),e.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this)),e},r.prototype.onResourceDestroy=function(e){e&&e.dispose()},r}(e.BinAnalyzer);e.SheetAnalyzer=t,__reflect(t.prototype,"RES.SheetAnalyzer")}(RES||(RES={}));var RES;!function(e){}(RES||(RES={}));var RES;!function(e){var t=function(t){function r(){var e=t.call(this)||this;return e.fileDic={},e.resItemDic=[],e.recycler=[],e}return __extends(r,t),r.prototype.loadFile=function(t,r,i){if(this.fileDic[t.name])return void r.call(i,t);var n=this.getLoader();this.resItemDic[n.$hashCode]={item:t,func:r,thisObject:i},n.load(e.$getVirtualUrl(t.url))},r.prototype.getLoader=function(){var e=this.recycler.pop();return e||(e=new egret.ImageLoader,e.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),e.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this)),e},r.prototype.onLoadFinish=function(e){var t=e.$target,r=this.resItemDic[t.$hashCode];delete this.resItemDic[t.$hashCode];var i=r.item,n=r.func;if(i.loaded=e.$type==egret.Event.COMPLETE,i.loaded){var o=new egret.Texture;o._setBitmapData(t.data),this.analyzeData(i,o)}this.recycler.push(t),n.call(r.thisObject,i)},r.prototype.analyzeData=function(e,t){var r=e.name;if(!this.fileDic[r]&&t){this.fileDic[r]=t;var i=e.data;if(i&&i.scale9grid){var n=i.scale9grid,o=n.split(",");t.scale9Grid=new egret.Rectangle(parseInt(o[0]),parseInt(o[1]),parseInt(o[2]),parseInt(o[3]))}}},r.prototype.getRes=function(e){return this.fileDic[e]},r.prototype.hasRes=function(e){var t=this.getRes(e);return null!=t},r.prototype.destroyRes=function(e){return this.fileDic[e]?(this.onResourceDestroy(this.fileDic[e]),delete this.fileDic[e],!0):!1},r.prototype.onResourceDestroy=function(e){e.dispose()},r}(e.AnalyzerBase);e.ImageAnalyzer=t,__reflect(t.prototype,"RES.ImageAnalyzer")}(RES||(RES={}));var RES;!function(e){var t=function(e){function t(){var t=e.call(this)||this;return t._dataFormat=egret.HttpResponseType.TEXT,t}return __extends(t,e),t}(e.BinAnalyzer);e.TextAnalyzer=t,__reflect(t.prototype,"RES.TextAnalyzer")}(RES||(RES={}));var RES;!function(e){var t=function(e){function t(){var t=e.call(this)||this;return t._dataFormat=egret.HttpResponseType.TEXT,t}return __extends(t,e),t.prototype.analyzeData=function(e,t){var r=e.name;if(!this.fileDic[r]&&t)try{var i=t;this.fileDic[r]=JSON.parse(i)}catch(n){egret.$warn(1017,e.url,t)}},t}(e.BinAnalyzer);e.JsonAnalyzer=t,__reflect(t.prototype,"RES.JsonAnalyzer")}(RES||(RES={}));var RES;!function(e){var t=function(t){function r(){var e=t.call(this)||this;return e.thread=2,e.loadingCount=0,e.callBack=null,e.resInstance=null,e.groupTotalDic={},e.numLoadedDic={},e.itemListDic={},e.groupErrorDic={},e.retryTimesDic={},e.maxRetryTimes=3,e.failedList=new Array,e.priorityQueue={},e.lazyLoadList=new Array,e.analyzerDic={},e.queueIndex=0,e}return __extends(r,t),r.prototype.isGroupInLoading=function(e){return void 0!==this.itemListDic[e]},r.prototype.loadGroup=function(t,r,i){if(void 0===i&&(i=0),!this.itemListDic[r]&&r){if(!t||0==t.length){egret.$warn(3201,r);var n=new e.ResourceEvent(e.ResourceEvent.GROUP_LOAD_ERROR);return n.groupName=r,void this.dispatchEvent(n)}this.priorityQueue[i]?this.priorityQueue[i].push(r):this.priorityQueue[i]=[r],this.itemListDic[r]=t;for(var o=t.length,s=0;o>s;s++){var a=t[s];a.groupName=r}this.groupTotalDic[r]=t.length,this.numLoadedDic[r]=0,this.next()}},r.prototype.loadItem=function(e){this.lazyLoadList.push(e),e.groupName="",this.next()},r.prototype.next=function(){for(;this.loadingCount0)return this.failedList.shift();var e=Number.NEGATIVE_INFINITY;for(var t in this.priorityQueue)e=Math.max(e,t);var r=this.priorityQueue[e];if(!r||0==r.length)return 0==this.lazyLoadList.length?null:this.lazyLoadList.pop();for(var i,n=r.length,o=0;n>o&&(this.queueIndex>=n&&(this.queueIndex=0),i=this.itemListDic[r[this.queueIndex]],!(i.length>0));o++)this.queueIndex++;return 0==i.length?null:i.shift()},r.prototype.onItemComplete=function(t){this.loadingCount--;var r=t.groupName;if(!t.loaded){var i=this.retryTimesDic[t.name]||1;if(!(i>this.maxRetryTimes))return this.retryTimesDic[t.name]=i+1,this.failedList.push(t),void this.next();delete this.retryTimesDic[t.name],e.ResourceEvent.dispatchResourceEvent(this.resInstance,e.ResourceEvent.ITEM_LOAD_ERROR,r,t)}if(r){this.numLoadedDic[r]++;var n=this.numLoadedDic[r],o=this.groupTotalDic[r];if(t.loaded||(this.groupErrorDic[r]=!0),e.ResourceEvent.dispatchResourceEvent(this.resInstance,e.ResourceEvent.GROUP_PROGRESS,r,t,n,o),n==o){var s=this.groupErrorDic[r];this.removeGroupName(r),delete this.groupTotalDic[r],delete this.numLoadedDic[r],delete this.itemListDic[r],delete this.groupErrorDic[r],s?e.ResourceEvent.dispatchResourceEvent(this,e.ResourceEvent.GROUP_LOAD_ERROR,r):e.ResourceEvent.dispatchResourceEvent(this,e.ResourceEvent.GROUP_COMPLETE,r)}}else this.callBack.call(this.resInstance,t);this.next()},r.prototype.removeGroupName=function(e){for(var t in this.priorityQueue){for(var r=this.priorityQueue[t],i=0,n=!1,o=r.length,s=0;o>s;s++){var a=r[s];if(a==e){r.splice(i,1),n=!0;break}i++}if(n){0==r.length&&delete this.priorityQueue[t];break}}},r}(egret.EventDispatcher);e.ResourceLoader=t,__reflect(t.prototype,"RES.ResourceLoader")}(RES||(RES={}));var RES;!function(e){var t=function(e){function t(){return e.call(this)||this}return __extends(t,e),t.prototype.analyzeConfig=function(e,t){var r,i=e.name,n="";try{var o=t;r=JSON.parse(o)}catch(s){}return r?n=this.getRelativePath(e.url,r.file):(r=t,n=this.getTexturePath(e.url,r)),this.sheetMap[i]=r,n},t.prototype.analyzeBitmap=function(e,t){var r=e.name;if(!this.fileDic[r]&&t){var i=this.sheetMap[r];delete this.sheetMap[r];var n=new egret.BitmapFont(t,i);this.fileDic[r]=n}},t.prototype.getTexturePath=function(e,t){var r="",i=t.split("\n"),n=i[2],o=n.indexOf('file="');return-1!=o&&(n=n.substring(o+6),o=n.indexOf('"'),r=n.substring(0,o)),e=e.split("\\").join("/"),o=e.lastIndexOf("/"),e=-1!=o?e.substring(0,o+1)+r:r},t.prototype.onResourceDestroy=function(e){e&&e.dispose()},t}(e.SheetAnalyzer);e.FontAnalyzer=t,__reflect(t.prototype,"RES.FontAnalyzer")}(RES||(RES={}));var RES;!function(e){var t=function(){function t(){this.keyMap={},this.groupDic={},e.configInstance=this}return t.prototype.getGroupByName=function(e){var t=new Array;if(!this.groupDic[e])return t;for(var r=this.groupDic[e],i=r.length,n=0;i>n;n++){var o=r[n];t.push(this.parseResourceItem(o))}return t},t.prototype.getRawGroupByName=function(e){return this.groupDic[e]?this.groupDic[e]:[]},t.prototype.createGroup=function(e,t,r){if(void 0===r&&(r=!1),!r&&this.groupDic[e]||!t||0==t.length)return!1;for(var i=this.groupDic,n=[],o=t.length,s=0;o>s;s++){var a=t[s],u=i[a];if(u)for(var c=u.length,l=0;c>l;l++){var p=u[l];-1==n.indexOf(p)&&n.push(p)}else{var p=this.keyMap[a];p?-1==n.indexOf(p)&&n.push(p):egret.$warn(3200,a)}}return 0==n.length?!1:(this.groupDic[e]=n,!0)},t.prototype.parseConfig=function(e,t){if(e){var r=e.resources;if(r)for(var i=r.length,n=0;i>n;n++){var o=r[n],s=o.url;s&&-1==s.indexOf("://")&&(o.url=t+s),this.addItemToKeyMap(o)}var a=e.groups;if(a)for(var u=a.length,n=0;u>n;n++){for(var c=a[n],l=[],p=c.keys.split(","),h=p.length,f=0;h>f;f++){var d=p[f].trim(),o=this.keyMap[d];o&&-1==l.indexOf(o)&&l.push(o)}this.groupDic[c.name]=l}}},t.prototype.addSubkey=function(e,t){var r=this.keyMap[t];r&&!this.keyMap[e]&&(this.keyMap[e]=r)},t.prototype.addItemToKeyMap=function(e){if(this.keyMap[e.name]||(this.keyMap[e.name]=e),e.hasOwnProperty("subkeys")){var t=e.subkeys.split(",");e.subkeys=t;for(var r=t.length,i=0;r>i;i++){var n=t[i];null==this.keyMap[n]&&(this.keyMap[n]=e)}}},t.prototype.getName=function(e){var t=this.keyMap[e];return t?t.name:""},t.prototype.getType=function(e){var t=this.keyMap[e];return t?t.type:""},t.prototype.getRawResourceItem=function(e){return this.keyMap[e]},t.prototype.getResourceItem=function(e){var t=this.keyMap[e];return t?this.parseResourceItem(t):null},t.prototype.parseResourceItem=function(t){var r=new e.ResourceItem(t.name,t.url,t.type);return r.data=t,r},t}();e.ResourceConfig=t,__reflect(t.prototype,"RES.ResourceConfig")}(RES||(RES={}));var RES;!function(e){var t=function(e){function t(){var t=e.call(this)||this;return t._dataFormat=egret.HttpResponseType.TEXT,t}return __extends(t,e),t.prototype.analyzeData=function(e,t){var r=e.name;if(!this.fileDic[r]&&t)try{var i=t,n=egret.XML.parse(i);this.fileDic[r]=n}catch(o){}},t}(e.BinAnalyzer);e.XMLAnalyzer=t,__reflect(t.prototype,"RES.XMLAnalyzer")}(RES||(RES={}));var RES;!function(e){var t=function(e){function t(t,r,i){void 0===r&&(r=!1),void 0===i&&(i=!1);var n=e.call(this,t,r,i)||this;return n.itemsLoaded=0,n.itemsTotal=0,n.groupName="",n.resItem=null,n}return __extends(t,e),t.dispatchResourceEvent=function(e,r,i,n,o,s){void 0===i&&(i=""),void 0===n&&(n=null),void 0===o&&(o=0),void 0===s&&(s=0);var a=egret.Event.create(t,r);a.groupName=i,a.resItem=n,a.itemsLoaded=o,a.itemsTotal=s;var u=e.dispatchEvent(a);return egret.Event.release(a),u},t}(egret.Event);t.ITEM_LOAD_ERROR="itemLoadError",t.CONFIG_COMPLETE="configComplete",t.CONFIG_LOAD_ERROR="configLoadError",t.GROUP_PROGRESS="groupProgress",t.GROUP_COMPLETE="groupComplete",t.GROUP_LOAD_ERROR="groupLoadError",e.ResourceEvent=t,__reflect(t.prototype,"RES.ResourceEvent")}(RES||(RES={}));var RES;!function(e){var t;!function(t){var r=function(e){function t(){var t=e.call(this)||this;return t._versionInfo={},t}return __extends(t,e),t.prototype.fetchVersion=function(e){e.onSuccess(null)},t.prototype.getChangeList=function(){return[]},t.prototype.getVirtualUrl=function(e){return e},t}(egret.EventDispatcher);t.Html5VersionController=r,__reflect(r.prototype,"RES.web.Html5VersionController",["RES.VersionController","RES.IVersionController"]),egret.Capabilities.runtimeType==egret.RuntimeType.WEB&&(e.VersionController=r)}(t=e.web||(e.web={}))}(RES||(RES={}));var RES;!function(e){var t;!function(t){var r=function(){function e(){this._versionInfo={},this._versionPath="",this._localFileArr=[]}return e.prototype.fetchVersion=function(e){var t=this;if(t._versionPath="all.manifest",t._versionInfo=t.getLocalData(t._versionPath),null==t._versionInfo)return void egret.callLater(function(){e.onFail(1,null)},t);var r=0,i=function(i){if(i)for(var n=0;ns;s++){var a=i[s],u=new e.ResourceItem(a.url,a.url,a.type);o.push(u)}var c={onSuccess:function(e){t.resLoader.loadGroup(o,r.GROUP_CONFIG,Number.MAX_VALUE)},onFail:function(r,i){e.ResourceEvent.dispatchResourceEvent(t,e.ResourceEvent.CONFIG_LOAD_ERROR)}};this.vcs?this.vcs.fetchVersion(c):this.resLoader.loadGroup(o,r.GROUP_CONFIG,Number.MAX_VALUE)},r.prototype.isGroupLoaded=function(e){return-1!=this.loadedGroups.indexOf(e)},r.prototype.getGroupByName=function(e){return this.resConfig.getGroupByName(e)},r.prototype.loadGroup=function(t,r){if(void 0===r&&(r=0),-1!=this.loadedGroups.indexOf(t))return void e.ResourceEvent.dispatchResourceEvent(this,e.ResourceEvent.GROUP_COMPLETE,t);if(!this.resLoader.isGroupInLoading(t))if(this.configComplete){var i=this.resConfig.getGroupByName(t);this.resLoader.loadGroup(i,t,r)}else this.groupNameList.push({name:t,priority:r})},r.prototype.createGroup=function(e,t,r){if(void 0===r&&(r=!1),r){var i=this.loadedGroups.indexOf(e);-1!=i&&this.loadedGroups.splice(i,1)}return this.resConfig.createGroup(e,t,r)},r.prototype.onGroupComp=function(t){if(t.groupName==r.GROUP_CONFIG){for(var i=this.loadingConfigList.length,n=0;i>n;n++){var o=this.loadingConfigList[n],s=this.$getAnalyzerByType(o.type),a=s.getRes(o.url);s.destroyRes(o.url),this.resConfig.parseConfig(a,o.resourceRoot)}this.configComplete=!0,this.loadingConfigList=null,e.ResourceEvent.dispatchResourceEvent(this,e.ResourceEvent.CONFIG_COMPLETE),this.loadDelayGroups()}else this.loadedGroups.push(t.groupName),this.dispatchEvent(t)},r.prototype.loadDelayGroups=function(){var e=this.groupNameList;this.groupNameList=[];for(var t=e.length,r=0;t>r;r++){var i=e[r];this.loadGroup(i.name,i.priority)}},r.prototype.onGroupError=function(t){t.groupName==r.GROUP_CONFIG?(this.loadingConfigList=null,e.ResourceEvent.dispatchResourceEvent(this,e.ResourceEvent.CONFIG_LOAD_ERROR)):this.dispatchEvent(t)},r.prototype.hasRes=function(t){var r=this.resConfig.getType(t);if(""==r){var i=e.AnalyzerBase.getStringTail(t);if(r=this.resConfig.getType(i),""==r)return!1}return!0},r.prototype.parseConfig=function(e,t){this.resConfig.parseConfig(e,t),this.configComplete||this.loadingConfigList||(this.configComplete=!0,this.loadDelayGroups())},r.prototype.getRes=function(t){var r=this.resConfig.getType(t);if(""==r){var i=e.AnalyzerBase.getStringPrefix(t);if(r=this.resConfig.getType(i),""==r)return null}var n=this.$getAnalyzerByType(r);return n.getRes(t)},r.prototype.getResAsync=function(t,r,i){var n=this.resConfig.getType(t),o=this.resConfig.getName(t);if(""==n&&(o=e.AnalyzerBase.getStringPrefix(t),n=this.resConfig.getType(o),""==n))return void egret.$callAsync(r,i);var s=this.$getAnalyzerByType(n),a=s.getRes(t);if(a)return void egret.$callAsync(r,i,a,t);var u={key:t,compFunc:r,thisObject:i};if(this.asyncDic[o])this.asyncDic[o].push(u);else{this.asyncDic[o]=[u];var c=this.resConfig.getResourceItem(o);this.resLoader.loadItem(c)}},r.prototype.getResByUrl=function(t,r,i,n){if(void 0===n&&(n=""),!t)return void egret.$callAsync(r,i);n||(n=this.getTypeByUrl(t)),null!=this._loadedUrlTypes[t]&&this._loadedUrlTypes[t]!=n&&egret.$warn(3202),this._loadedUrlTypes[t]=n;var o=this.$getAnalyzerByType(n),s=t,a=o.getRes(s);if(a)return void egret.$callAsync(r,i,a,t);var u={key:s,compFunc:r,thisObject:i};if(this.asyncDic[s])this.asyncDic[s].push(u);else{this.asyncDic[s]=[u];var c=new e.ResourceItem(s,t,n);this.resLoader.loadItem(c)}},r.prototype.getTypeByUrl=function(t){var r=t.substr(t.lastIndexOf(".")+1);r&&(r=r.toLowerCase());var i;switch(r){case e.ResourceItem.TYPE_XML:case e.ResourceItem.TYPE_JSON:case e.ResourceItem.TYPE_SHEET:i=r;break;case"png":case"jpg":case"gif":case"jpeg":case"bmp":i=e.ResourceItem.TYPE_IMAGE;break;case"fnt":i=e.ResourceItem.TYPE_FONT;break;case"txt":i=e.ResourceItem.TYPE_TEXT;break;case"mp3":case"ogg":case"mpeg":case"wav":case"m4a":case"mp4":case"aiff":case"wma":case"mid":i=e.ResourceItem.TYPE_SOUND;break;default:i=e.ResourceItem.TYPE_BIN}return i},r.prototype.onResourceItemComp=function(e){var t=this.asyncDic[e.name];delete this.asyncDic[e.name];for(var r=this.$getAnalyzerByType(e.type),i=t.length,n=0;i>n;n++){var o=t[n],s=r.getRes(o.key);o.compFunc.call(o.thisObject,s,o.key)}},r.prototype.destroyRes=function(e,t){void 0===t&&(t=!0);var r=this.resConfig.getRawGroupByName(e);if(r&&r.length>0){var i=this.loadedGroups.indexOf(e);-1!=i&&this.loadedGroups.splice(i,1);for(var n=r.length,o=0;n>o;o++){var s=r[o];if(!t&&this.isResInLoadedGroup(s.name));else{s.loaded=!1;var a=this.$getAnalyzerByType(s.type);a.destroyRes(s.name),this.removeLoadedGroupsByItemName(s.name)}}return!0}var u=this.resConfig.getType(e);if(""==u){if(u=this._loadedUrlTypes[e],null==u||""==u)return!1;delete this._loadedUrlTypes[e];var c=this.$getAnalyzerByType(u);return c.destroyRes(e),!0}var s=this.resConfig.getRawResourceItem(e);s.loaded=!1;var a=this.$getAnalyzerByType(u),l=a.destroyRes(e);return this.removeLoadedGroupsByItemName(s.name),l},r.prototype.removeLoadedGroupsByItemName=function(e){for(var t=this.loadedGroups,r=t.length,i=0;r>i;i++)for(var n=this.resConfig.getRawGroupByName(t[i]),o=n.length,s=0;o>s;s++){var a=n[s];if(a.name==e){t.splice(i,1),i--,r=t.length;break}}},r.prototype.isResInLoadedGroup=function(e){for(var t=this.loadedGroups,r=t.length,i=0;r>i;i++)for(var n=this.resConfig.getRawGroupByName(t[i]),o=n.length,s=0;o>s;s++){var a=n[s];if(a.name==e)return!0}return!1},r.prototype.setMaxLoadingThread=function(e){1>e&&(e=1),this.resLoader.thread=e},r.prototype.setMaxRetryTimes=function(e){e=Math.max(e,0),this.resLoader.maxRetryTimes=e},r}(egret.EventDispatcher);_.GROUP_CONFIG="RES__CONFIG",__reflect(_.prototype,"Resource");var I=new _}(RES||(RES={}));var RES;!function(e){var t=function(t){function r(){var e=t.call(this)||this;return e.sheetMap={},e.recyclerIamge=[],e._dataFormat=egret.HttpResponseType.TEXT,e}return __extends(r,t),r.prototype.onLoadFinish=function(e){var t=e.target,r=this.resItemDic[t.$hashCode];delete this.resItemDic[t.hashCode];var i=r.item,n=r.func;if(i.loaded=e.type==egret.Event.COMPLETE,i.loaded)if(t instanceof egret.HttpRequest){i.loaded=!1;var o=this.analyzeConfig(i,t.response);if(o)return this.loadImage(o,r),void this.recycler.push(t)}else this.analyzeBitmap(i,t.data);t instanceof egret.HttpRequest?this.recycler.push(t):this.recyclerIamge.push(t),n.call(r.thisObject,i)},r.prototype.analyzeConfig=function(e,t){var r,i=e.name,n="";try{var o=t;r=JSON.parse(o)}catch(s){egret.$warn(1017,e.url,t)}if(r)if(this.sheetMap[i]=r,r.file)n=this.getRelativePath(e.url,r.file);else{var a=e.url.split("?"),u=a[0].split("/");u[u.length-1]=u[u.length-1].split(".")[0]+".png",n="";for(var c=0;cu;u++){i=t.res[o[u].res];var c=new egret.Texture;c._bitmapData=e,c.$initData(i.x,i.y,i.w,i.h,o[u].x,o[u].y,o[u].sourceW,o[u].sourceH,e.width,e.height)}return a},r.prototype.destroyRes=function(e){var t=this.fileDic[e];return t?(delete this.fileDic[e],!0):!1},r.prototype.loadImage=function(t,r){var i=this.getImageLoader();this.resItemDic[i.hashCode]=r,i.load(e.$getVirtualUrl(t))},r.prototype.getImageLoader=function(){var e=this.recyclerIamge.pop();return e||(e=new egret.ImageLoader,e.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),e.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this)),e},r}(e.BinAnalyzer);e.AnimationAnalyzer=t,__reflect(t.prototype,"RES.AnimationAnalyzer")}(RES||(RES={}));var egret;!function(e){e.$locale_strings=e.$locale_strings||{},e.$locale_strings.en_US=e.$locale_strings.en_US||{};var t=e.$locale_strings.en_US;t[3200]="RES.createGroup() passed in non-existed key value in configuration: {0}",t[3201]='RES loaded non-existed or empty resource group:"{0}"',t[3202]="Do not use the different types of ways to load the same material!",t[3203]="Can't find the analyzer of the specified file type:{0}。 Please register the specified analyzer in the initialization of the project first,then start the resource loading process。"}(egret||(egret={}));var egret;!function(e){e.$locale_strings=e.$locale_strings||{},e.$locale_strings.zh_CN=e.$locale_strings.zh_CN||{};var t=e.$locale_strings.zh_CN;t[3200]="RES.createGroup()传入了配置中不存在的键值: {0}",t[3201]='RES加载了不存在或空的资源组:"{0}"',t[3202]="请不要使用不同的类型方式来加载同一个素材!",t[3203]="找不到指定文件类型的解析器:{0}。 请先在项目初始化里注册指定文件类型的解析器,再启动资源加载。"}(egret||(egret={})); -------------------------------------------------------------------------------- /demo/libs/modules/socket/socket.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace egret { 2 | /** 3 | * @private 4 | * @version Egret 2.4 5 | * @platform Web,Native 6 | * @language en_US 7 | */ 8 | /** 9 | * @private 10 | * @version Egret 2.4 11 | * @platform Web,Native 12 | * @language zh_CN 13 | */ 14 | interface ISocket { 15 | /** 16 | * 连接 17 | * @method egret.ISocket#connect 18 | * @version Egret 2.4 19 | * @platform Web,Native 20 | * @language en_US 21 | */ 22 | /** 23 | * 连接 24 | * @method egret.ISocket#connect 25 | * @version Egret 2.4 26 | * @platform Web,Native 27 | * @language zh_CN 28 | */ 29 | connect(host: string, port: number): void; 30 | /** 31 | * 连接 32 | * @method egret.ISocket#connect 33 | */ 34 | connectByUrl(url: string): void; 35 | /** 36 | * 37 | * @param onConnect 38 | * @param onClose 39 | * @param onSocketData 40 | * @param onError 41 | * @param thisObject 42 | * @version Egret 2.4 43 | * @platform Web,Native 44 | * @language en_US 45 | */ 46 | /** 47 | * 48 | * @param onConnect 49 | * @param onClose 50 | * @param onSocketData 51 | * @param onError 52 | * @param thisObject 53 | * @version Egret 2.4 54 | * @platform Web,Native 55 | * @language zh_CN 56 | */ 57 | addCallBacks(onConnect: Function, onClose: Function, onSocketData: Function, onError: Function, thisObject: any): void; 58 | /** 59 | * 60 | * @param message 61 | * @version Egret 2.4 62 | * @platform Web,Native 63 | * @language en_US 64 | */ 65 | /** 66 | * 67 | * @param message 68 | * @version Egret 2.4 69 | * @platform Web,Native 70 | * @language zh_CN 71 | */ 72 | send(message: any): void; 73 | /** 74 | * 75 | * @version Egret 2.4 76 | * @platform Web,Native 77 | * @language en_US 78 | */ 79 | /** 80 | * 81 | * @version Egret 2.4 82 | * @platform Web,Native 83 | * @language zh_CN 84 | */ 85 | close(): void; 86 | } 87 | /** 88 | * @version Egret 2.4 89 | * @platform Web,Native 90 | * @language en_US 91 | */ 92 | /** 93 | * @version Egret 2.4 94 | * @platform Web,Native 95 | * @language zh_CN 96 | */ 97 | let ISocket: { 98 | new (): ISocket; 99 | }; 100 | } 101 | declare namespace egret { 102 | /** 103 | * The egret.WebSocket class enables code to establish a TCP socket connection, for sending and receiving character string or binary data. 104 | * To use the methods of the egret.WebSocket class, first use the constructor function new egret.WebSocket to create an egret.WebSocket object. 105 | * The socket transmits and receives data in asynchronous mode. 106 | * @event egret.Event.CONNECT Successfully connect to the server。 107 | * @event egret.ProgressEvent.SOCKET_DATA Receiving server data。 108 | * @event egret.Event.CLOSE Dispatched when the server closes the connection. 109 | * @event egret.ProgressEvent Dispatched when an IO error causes a send or load operation to fail. 110 | * @see http://edn.egret.com/cn/docs/page/602 WebSocket 111 | * @version Egret 2.4 112 | * @platform Web,Native 113 | * @includeExample extension/socket/WebSocket.ts 114 | * @language en_US 115 | */ 116 | /** 117 | * egret.WebSocket 类启用代码以建立传输控制协议 (TCP) 套接字连接,用于发送和接收字符串或二进制数据。 118 | * 要使用 egret.WebSocket 类的方法,请先使用构造函数 new egret.WebSocket 创建一个 egret.WebSocket 对象。 119 | * 套接字以异步方式传输和接收数据。 120 | * @event egret.Event.CONNECT 连接服务器成功。 121 | * @event egret.ProgressEvent.SOCKET_DATA 接收服务器数据。 122 | * @event egret.Event.CLOSE 在服务器关闭连接时调度。 123 | * @event egret.IOErrorEvent.IO_ERROR 在出现输入/输出错误并导致发送或加载操作失败时调度。。 124 | * @see http://edn.egret.com/cn/docs/page/602 WebSocket 125 | * @version Egret 2.4 126 | * @platform Web,Native 127 | * @includeExample extension/socket/WebSocket.ts 128 | * @language zh_CN 129 | */ 130 | class WebSocket extends egret.EventDispatcher { 131 | /** 132 | * Send and receive data in character string format 133 | * @version Egret 2.4 134 | * @platform Web,Native 135 | * @language en_US 136 | */ 137 | /** 138 | * 以字符串格式发送和接收数据 139 | * @version Egret 2.4 140 | * @platform Web,Native 141 | * @language zh_CN 142 | */ 143 | static TYPE_STRING: string; 144 | /** 145 | * Send and receive data in binary format 146 | * @version Egret 2.4 147 | * @platform Web,Native 148 | * @language en_US 149 | */ 150 | /** 151 | * 以二进制格式发送和接收数据 152 | * @version Egret 2.4 153 | * @platform Web,Native 154 | * @language zh_CN 155 | */ 156 | static TYPE_BINARY: string; 157 | /** 158 | * @private 159 | */ 160 | private socket; 161 | /** 162 | * @private 163 | */ 164 | private _writeMessage; 165 | /** 166 | * @private 167 | */ 168 | private _readMessage; 169 | /** 170 | * @private 171 | */ 172 | private _connected; 173 | /** 174 | * @private 175 | */ 176 | private _connecting; 177 | /** 178 | * Create an egret.WebSocket object 179 | * This parameter is reserved for later versions. The connection address and port number are imported in the connect function 180 | * @version Egret 2.4 181 | * @platform Web,Native 182 | * @language en_US 183 | */ 184 | /** 185 | * 创建一个 egret.WebSocket 对象 186 | * 参数为预留参数,现版本暂不处理,连接地址和端口号在 connect 函数中传入 187 | * @version Egret 2.4 188 | * @platform Web,Native 189 | * @language zh_CN 190 | */ 191 | constructor(host?: string, port?: number); 192 | /** 193 | * Connect the socket to the specified host and port number 194 | * @param host Name or IP address of the host to be connected 195 | * @param port Port number to be connected 196 | * @version Egret 2.4 197 | * @platform Web,Native 198 | * @language en_US 199 | */ 200 | /** 201 | * 将套接字连接到指定的主机和端口 202 | * @param host 要连接到的主机的名称或 IP 地址 203 | * @param port 要连接到的端口号 204 | * @version Egret 2.4 205 | * @platform Web,Native 206 | * @language zh_CN 207 | */ 208 | connect(host: string, port: number): void; 209 | /** 210 | * 根据提供的url连接 211 | * @param url 全地址。如ws://echo.websocket.org:80 212 | */ 213 | connectByUrl(url: string): void; 214 | /** 215 | * Closesocket 216 | * @version Egret 2.4 217 | * @platform Web,Native 218 | * @language en_US 219 | */ 220 | /** 221 | * 关闭套接字 222 | * @version Egret 2.4 223 | * @platform Web,Native 224 | * @language zh_CN 225 | */ 226 | close(): void; 227 | /** 228 | * @private 229 | * 230 | */ 231 | private onConnect(); 232 | /** 233 | * @private 234 | * 235 | */ 236 | private onClose(); 237 | /** 238 | * @private 239 | * 240 | */ 241 | private onError(); 242 | /** 243 | * @private 244 | * 245 | * @param message 246 | */ 247 | private onSocketData(message); 248 | /** 249 | * Refresh all data accumulated in the output buffer area of the socket 250 | * @version Egret 2.4 251 | * @platform Web,Native 252 | * @language en_US 253 | */ 254 | /** 255 | * 对套接字输出缓冲区中积累的所有数据进行刷新 256 | * @version Egret 2.4 257 | * @platform Web,Native 258 | * @language zh_CN 259 | */ 260 | flush(): void; 261 | /** 262 | * @private 263 | */ 264 | private _isReadySend; 265 | /** 266 | * Write data in character string in the socket 267 | * @param message The character string to be written in the socket 268 | * @version Egret 2.4 269 | * @platform Web,Native 270 | * @language en_US 271 | */ 272 | /** 273 | * 将字符串数据写入套接字 274 | * @param message 要写入套接字的字符串 275 | * @version Egret 2.4 276 | * @platform Web,Native 277 | * @language zh_CN 278 | */ 279 | writeUTF(message: string): void; 280 | /** 281 | * Read a UTF-8 character string from the socket 282 | * @returns {string} 283 | * @version Egret 2.4 284 | * @platform Web,Native 285 | * @language en_US 286 | */ 287 | /** 288 | * 从套接字读取一个 UTF-8 字符串 289 | * @returns {string} 290 | * @version Egret 2.4 291 | * @platform Web,Native 292 | * @language zh_CN 293 | */ 294 | readUTF(): string; 295 | /** 296 | * @private 297 | */ 298 | private _readByte; 299 | /** 300 | * @private 301 | */ 302 | private _writeByte; 303 | /** 304 | * @private 305 | */ 306 | private _bytesWrite; 307 | /** 308 | * Write a series of bytes from the specified byte array. The writing operation starts from the location expressed by offset. 309 | * If the length parameter is ignored, the default length 0 indicates that data is written from offset in the entire buffer area. 310 | * If the offset parameter is ignored, data is written in the entire buffer area. 311 | * @param bytes The ByteArray object where data is read from 312 | * @param offset Zero-based offset in the ByteArray object. From here start performing data writing 313 | * @param length Number of bytes to be written Default value 0 indicates data is written in the entire buffer area from the value specified by the offset parameter 314 | * @version Egret 2.4 315 | * @platform Web,Native 316 | * @language en_US 317 | */ 318 | /** 319 | * 从指定的字节数组写入一系列字节。写入操作从 offset 指定的位置开始。 320 | * 如果省略了 length 参数,则默认长度 0 将导致该方法从 offset 开始写入整个缓冲区。 321 | * 如果还省略了 offset 参数,则写入整个缓冲区。 322 | * @param bytes 要从中读取数据的 ByteArray 对象 323 | * @param offset ByteArray 对象中从零开始的偏移量,应由此开始执行数据写入 324 | * @param length 要写入的字节数。默认值 0 导致从 offset 参数指定的值开始写入整个缓冲区 325 | * @version Egret 2.4 326 | * @platform Web,Native 327 | * @language zh_CN 328 | */ 329 | writeBytes(bytes: ByteArray, offset?: number, length?: number): void; 330 | /** 331 | * Read data byte number specified by the length parameter from the socket. Read these bytes into the specified byte array starting from the location expressed by offset. 332 | * @param bytes The ByteArray object that data is read into 333 | * @param offset The offset for data reading starts from this byte array 334 | * @param length Byte number to be read Default value 0 indicates reading all available data 335 | * @version Egret 2.4 336 | * @platform Web,Native 337 | * @language en_US 338 | */ 339 | /** 340 | * 从套接字读取 length 参数指定的数据字节数。从 offset 所表示的位置开始,将这些字节读入指定的字节数组 341 | * @param bytes 要将数据读入的 ByteArray 对象 342 | * @param offset 数据读取的偏移量应从该字节数组中开始 343 | * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 344 | * @version Egret 2.4 345 | * @platform Web,Native 346 | * @language zh_CN 347 | */ 348 | readBytes(bytes: ByteArray, offset?: number, length?: number): void; 349 | /** 350 | * Indicates whether the Socket object is connected currently 351 | * @version Egret 2.4 352 | * @platform Web,Native 353 | * @language en_US 354 | */ 355 | /** 356 | * 表示此 Socket 对象目前是否已连接 357 | * @version Egret 2.4 358 | * @platform Web,Native 359 | * @language zh_CN 360 | */ 361 | readonly connected: boolean; 362 | /** 363 | * @private 364 | */ 365 | private _type; 366 | /** 367 | * Format for sending and receiving data. The default setting is the character string format 368 | * @version Egret 2.4 369 | * @platform Web,Native 370 | * @language en_US 371 | */ 372 | /** 373 | * 发送和接收数据的格式,默认是字符串格式 374 | * @version Egret 2.4 375 | * @platform Web,Native 376 | * @language zh_CN 377 | */ 378 | type: string; 379 | } 380 | } 381 | declare namespace egret.native { 382 | /** 383 | * @private 384 | */ 385 | class NativeSocket implements ISocket { 386 | private socket; 387 | constructor(); 388 | private onConnect; 389 | private onClose; 390 | private onSocketData; 391 | private onError; 392 | private thisObject; 393 | addCallBacks(onConnect: Function, onClose: Function, onSocketData: Function, onError: Function, thisObject: any): void; 394 | private host; 395 | private port; 396 | connect(host: string, port: number): void; 397 | connectByUrl(url: string): void; 398 | private _bindEvent(); 399 | send(message: any): void; 400 | close(): void; 401 | } 402 | } 403 | declare namespace egret.web { 404 | /** 405 | * @private 406 | */ 407 | class HTML5WebSocket implements ISocket { 408 | private socket; 409 | constructor(); 410 | private onConnect; 411 | private onClose; 412 | private onSocketData; 413 | private onError; 414 | private thisObject; 415 | addCallBacks(onConnect: Function, onClose: Function, onSocketData: Function, onError: Function, thisObject: any): void; 416 | private host; 417 | private port; 418 | connect(host: string, port: number): void; 419 | connectByUrl(url: string): void; 420 | private _bindEvent(); 421 | send(message: any): void; 422 | close(): void; 423 | } 424 | } 425 | -------------------------------------------------------------------------------- /demo/libs/modules/socket/socket.min.js: -------------------------------------------------------------------------------- 1 | var __reflect=this&&this.__reflect||function(t,e,o){t.__class__=e,o?o.push(e):o=[e],t.__types__=t.__types__?o.concat(t.__types__):o},__extends=this&&this.__extends||function(t,e){function o(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)},egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(e){function o(n,i){void 0===n&&(n=""),void 0===i&&(i=0);var s=e.call(this)||this;return s._writeMessage="",s._readMessage="",s._connected=!1,s._connecting=!1,s._isReadySend=!1,s._bytesWrite=!1,s._type=o.TYPE_STRING,s._connected=!1,s._writeMessage="",s._readMessage="",s.socket=new t.ISocket,s.socket.addCallBacks(s.onConnect,s.onClose,s.onSocketData,s.onError,s),s}return __extends(o,e),o.prototype.connect=function(t,e){this._connecting||this._connected||(this._connecting=!0,this.socket.connect(t,e))},o.prototype.connectByUrl=function(t){this._connecting||this._connected||(this._connecting=!0,this.socket.connectByUrl(t))},o.prototype.close=function(){this._connected&&this.socket.close()},o.prototype.onConnect=function(){this._connected=!0,this._connecting=!1,this.dispatchEventWith(t.Event.CONNECT)},o.prototype.onClose=function(){this._connected=!1,this.dispatchEventWith(t.Event.CLOSE)},o.prototype.onError=function(){this._connecting&&(this._connecting=!1),this.dispatchEventWith(t.IOErrorEvent.IO_ERROR)},o.prototype.onSocketData=function(e){"string"==typeof e?this._readMessage+=e:this._readByte._writeUint8Array(new Uint8Array(e)),t.ProgressEvent.dispatchProgressEvent(this,t.ProgressEvent.SOCKET_DATA)},o.prototype.flush=function(){return this._connected?(this._writeMessage&&(this.socket.send(this._writeMessage),this._writeMessage=""),this._bytesWrite&&(this.socket.send(this._writeByte.buffer),this._bytesWrite=!1,this._writeByte.clear()),void(this._isReadySend=!1)):void t.$warn(3101)},o.prototype.writeUTF=function(e){return this._connected?(this._type==o.TYPE_BINARY?(this._bytesWrite=!0,this._writeByte.writeUTF(e)):this._writeMessage+=e,void this.flush()):void t.$warn(3101)},o.prototype.readUTF=function(){var t;return this._type==o.TYPE_BINARY?(this._readByte.position=0,t=this._readByte.readUTF(),this._readByte.clear()):(t=this._readMessage,this._readMessage=""),t},o.prototype.writeBytes=function(e,o,n){return void 0===o&&(o=0),void 0===n&&(n=0),this._connected?this._writeByte?(this._bytesWrite=!0,this._writeByte.writeBytes(e,o,n),void this.flush()):void t.$warn(3102):void t.$warn(3101)},o.prototype.readBytes=function(e,o,n){return void 0===o&&(o=0),void 0===n&&(n=0),this._readByte?(this._readByte.position=0,this._readByte.readBytes(e,o,n),void this._readByte.clear()):void t.$warn(3102)},Object.defineProperty(o.prototype,"connected",{get:function(){return this._connected},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"type",{get:function(){return this._type},set:function(e){this._type=e,e!=o.TYPE_BINARY||this._writeByte||(this._readByte=new t.ByteArray,this._writeByte=new t.ByteArray)},enumerable:!0,configurable:!0}),o}(t.EventDispatcher);e.TYPE_STRING="webSocketTypeString",e.TYPE_BINARY="webSocketTypeBinary",t.WebSocket=e,__reflect(e.prototype,"egret.WebSocket")}(egret||(egret={}));var egret;!function(t){var e;!function(e){var o=function(){function t(){this.host="",this.port=0}return t.prototype.addCallBacks=function(t,e,o,n,i){this.onConnect=t,this.onClose=e,this.onSocketData=o,this.onError=n,this.thisObject=i},t.prototype.connect=function(t,e){this.host=t,this.port=e;var o="ws://"+this.host+":"+this.port;this.socket=new __global.egret_native.WebSocket(o),this._bindEvent()},t.prototype.connectByUrl=function(t){this.socket=new __global.egret_native.WebSocket(t),this._bindEvent()},t.prototype._bindEvent=function(){var t=this,e=this.socket;e.onOpen=function(){t.onConnect&&t.onConnect.call(t.thisObject)},e.onClose=function(){t.onClose&&t.onClose.call(t.thisObject)},e.onError=function(e){t.onError&&t.onError.call(t.thisObject)},e.onMessage=function(e){t.onSocketData&&t.onSocketData.call(t.thisObject,e)}},t.prototype.send=function(t){this.socket.send(t)},t.prototype.close=function(){this.socket.close()},t}();e.NativeSocket=o,__reflect(o.prototype,"egret.native.NativeSocket",["egret.ISocket"]),t.Capabilities.runtimeType==t.RuntimeType.NATIVE&&(t.ISocket=o)}(e=t["native"]||(t["native"]={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var o=function(){function e(){this.host="",this.port=0,window.WebSocket||t.$error(3100)}return e.prototype.addCallBacks=function(t,e,o,n,i){this.onConnect=t,this.onClose=e,this.onSocketData=o,this.onError=n,this.thisObject=i},e.prototype.connect=function(t,e){this.host=t,this.port=e;var o="ws://"+this.host+":"+this.port;this.socket=new window.WebSocket(o),this.socket.binaryType="arraybuffer",this._bindEvent()},e.prototype.connectByUrl=function(t){this.socket=new window.WebSocket(t),this.socket.binaryType="arraybuffer",this._bindEvent()},e.prototype._bindEvent=function(){var t=this,e=this.socket;e.onopen=function(){t.onConnect&&t.onConnect.call(t.thisObject)},e.onclose=function(e){t.onClose&&t.onClose.call(t.thisObject)},e.onerror=function(e){t.onError&&t.onError.call(t.thisObject)},e.onmessage=function(e){t.onSocketData&&t.onSocketData.call(t.thisObject,e.data)}},e.prototype.send=function(t){this.socket.send(t)},e.prototype.close=function(){this.socket.close()},e}();e.HTML5WebSocket=o,__reflect(o.prototype,"egret.web.HTML5WebSocket",["egret.ISocket"]),t.Capabilities.runtimeType==t.RuntimeType.WEB&&(t.ISocket=o)}(e=t.web||(t.web={}))}(egret||(egret={})); -------------------------------------------------------------------------------- /demo/libs/modules/starlingSwf/starlingSwf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | declare module starlingswf { 5 | /**Sprite*/ 6 | class SwfSprite extends egret.DisplayObjectContainer { 7 | getTextField(name: string): egret.TextField; 8 | getMovie(name: string): starlingswf.SwfMovieClip; 9 | getSprite(name: string): starlingswf.SwfSprite; 10 | getImage(name: string): egret.Bitmap; 11 | getButton(name: string): starlingswf.SwfButton; 12 | } 13 | } 14 | /** 15 | * Created by zmliu on 14-5-11. 16 | */ 17 | declare module starlingswf { 18 | /** 19 | * 动画接口 20 | * */ 21 | interface ISwfAnimation { 22 | update(): void; 23 | getStage(): egret.Stage; 24 | } 25 | } 26 | /** 27 | * Created by zmliu on 14-5-11. 28 | */ 29 | declare module starlingswf { 30 | /** 31 | * Swf文档类 32 | * */ 33 | class Swf { 34 | static dataKey_Sprite: string; 35 | static dataKey_Image: string; 36 | static dataKey_MovieClip: string; 37 | static dataKey_TextField: string; 38 | static dataKey_Button: string; 39 | static dataKey_Scale9: string; 40 | static dataKey_ShapeImg: string; 41 | static dataKey_Component: string; 42 | static dataKey_Particle: string; 43 | private _createDisplayFuns; 44 | private _swfData; 45 | swfUpdateManager: starlingswf.SwfUpdateManager; 46 | constructor(swfData: Object, fps?: number); 47 | createSprite(name: string, data?: any[], sprData?: any[]): starlingswf.SwfSprite; 48 | createMovie(name: string, data?: any[]): starlingswf.SwfMovieClip; 49 | /** 50 | * 创建按钮 51 | * */ 52 | createButton(name: string, data?: any[]): starlingswf.SwfButton; 53 | createImage(name: string, data?: any[]): egret.Bitmap; 54 | createS9Image(name: string, data?: any[]): egret.Bitmap; 55 | createShapeImage(name: string, data?: any[]): egret.Bitmap; 56 | createTextField(name: String, data?: any[]): egret.TextField; 57 | /** 创建文本的滤镜 */ 58 | createTextFieldFilter(textField: egret.TextField, filterObjects: Object): void; 59 | } 60 | } 61 | declare module starlingswf { 62 | class SwfAnalyzer extends RES.BinAnalyzer { 63 | constructor(); 64 | /** 65 | * 解析并缓存加载成功的数据 66 | */ 67 | analyzeData(resItem: RES.ResourceItem, data: any): void; 68 | } 69 | } 70 | /** 71 | * Created by zmliu on 14-5-11. 72 | */ 73 | declare module starlingswf { 74 | /** 动画更新管理器 */ 75 | class SwfUpdateManager { 76 | private _animations; 77 | private _addQueue; 78 | private _removeQueue; 79 | private _fps; 80 | private _fpsTime; 81 | private _currentTime; 82 | static createSwfUpdateManager(fps: number): SwfUpdateManager; 83 | setFps(fps: number): void; 84 | addSwfAnimation(animation: starlingswf.ISwfAnimation): void; 85 | removeSwfAnimation(animation: starlingswf.ISwfAnimation): void; 86 | private updateAdd(); 87 | private updateRemove(); 88 | private update(time); 89 | } 90 | } 91 | /** 92 | * Created by zmliu on 14-9-25. 93 | */ 94 | declare module starlingswf { 95 | class SwfBlendMode { 96 | static modes: Object; 97 | static setBlendMode(display: egret.DisplayObject, blendMode: string): void; 98 | } 99 | } 100 | declare module lzm { 101 | class BasePanel extends egret.DisplayObjectContainer { 102 | constructor(); 103 | addToStage(e: egret.Event): void; 104 | removeFromStage(e: egret.Event): void; 105 | gotoPanel(panel: lzm.BasePanel): void; 106 | dispose(): void; 107 | } 108 | } 109 | declare module starlingswf { 110 | class SwfButton extends starlingswf.SwfSprite { 111 | static onClick: string; 112 | skin: SwfSprite; 113 | defScale: number; 114 | constructor(skin: starlingswf.SwfSprite); 115 | mouseDown(evt: egret.TouchEvent): void; 116 | mouseUp(evt: egret.TouchEvent): void; 117 | mouseClick(evt: egret.TouchEvent): void; 118 | setEnable(val: boolean): void; 119 | dispose(): void; 120 | } 121 | } 122 | /** 123 | * Created by zmliu on 14-5-11. 124 | */ 125 | declare module starlingswf { 126 | class SwfMovieClip extends starlingswf.SwfSprite implements starlingswf.ISwfAnimation { 127 | private _ownerSwf; 128 | private _frames; 129 | private _labels; 130 | private _frameEvents; 131 | private _displayObjects; 132 | private _startFrame; 133 | private _endFrame; 134 | private _currentFrame; 135 | private _currentLabel; 136 | private _isPlay; 137 | loop: boolean; 138 | private _completeFunction; 139 | private _hasCompleteListener; 140 | constructor(frames: any[], labels: any[], displayObjects: Object, ownerSwf: starlingswf.Swf, frameEvents?: Object); 141 | getStage(): egret.Stage; 142 | update(): void; 143 | private __frameInfos; 144 | setCurrentFrame(frame: number): void; 145 | getCurrentFrame(): number; 146 | /** 147 | * 播放 148 | * */ 149 | play(): void; 150 | /** 151 | * 停止 152 | * @param stopChild 是否停止子动画 153 | * */ 154 | stop(stopChild?: boolean): void; 155 | gotoAndStop(frame: Object, stopChild?: boolean): void; 156 | gotoAndPlay(frame: Object): void; 157 | private goTo(frame); 158 | private getLabelData(label); 159 | /** 160 | * 是否再播放 161 | * */ 162 | isPlay(): boolean; 163 | /** 164 | * 总共有多少帧 165 | * */ 166 | totalFrames(): number; 167 | /** 168 | * 返回当前播放的是哪一个标签 169 | * */ 170 | currentLabel(): string; 171 | /** 172 | * 获取所有标签 173 | * */ 174 | labels(): any[]; 175 | /** 176 | * 是否包含某个标签 177 | * */ 178 | hasLabel(label: String): Boolean; 179 | addEventListener1(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; 180 | removeEventListener1(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; 181 | private removeAllChilds(); 182 | } 183 | } 184 | declare module lzm { 185 | class Alert { 186 | private static background; 187 | private static dialogs; 188 | private static root; 189 | private static stageWidth; 190 | private static stageHeight; 191 | static init(stage: egret.Stage): void; 192 | private static container(); 193 | private static width(); 194 | private static height(); 195 | private static initBackGround(); 196 | static show(display: egret.DisplayObject): void; 197 | static alert(dialog: egret.DisplayObject, setXY?: boolean): void; 198 | private static dialogAddToStage(e); 199 | private static dialogRemoveFromStage(e); 200 | } 201 | } 202 | declare module lzm { 203 | class HttpClient { 204 | /** 205 | * 请求url 206 | */ 207 | static send(url: string, params: Object, completeFunction?: Function, timeoutFunction?: Function, method?: String): void; 208 | static getRequestPars(params: Object): string; 209 | } 210 | } 211 | declare module lzm { 212 | class JSONWebSocketClient { 213 | private socket; 214 | private host; 215 | private port; 216 | isConnect: boolean; 217 | onConnectCallBack: Function; 218 | onIOErrorCallBack: Function; 219 | onCloseCallBack: Function; 220 | onDataCallBack: Function; 221 | constructor(host: string, port: number); 222 | connect(): void; 223 | sendData(data: Object): void; 224 | private onSocketOpen(); 225 | private onReceiveMessage(e); 226 | private onSocketClose(e); 227 | private onSocketIOError(e); 228 | dispose(): void; 229 | } 230 | } 231 | -------------------------------------------------------------------------------- /demo/libs/modules/starlingSwf/starlingSwf.min.js: -------------------------------------------------------------------------------- 1 | var __extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},starlingswf;!function(t){var e=function(t){function e(){return t.apply(this,arguments)||this}return __extends(e,t),e.prototype.getTextField=function(t){return this.getChildByName(t)},e.prototype.getMovie=function(t){return this.getChildByName(t)},e.prototype.getSprite=function(t){return this.getChildByName(t)},e.prototype.getImage=function(t){return this.getChildByName(t)},e.prototype.getButton=function(t){return this.getChildByName(t)},e}(egret.DisplayObjectContainer);t.SwfSprite=e}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(){function e(n,r){void 0===r&&(r=24),this._swfData=n,this._createDisplayFuns=new Object,this._createDisplayFuns[e.dataKey_Sprite]=this.createSprite,this._createDisplayFuns[e.dataKey_MovieClip]=this.createMovie,this._createDisplayFuns[e.dataKey_Button]=this.createButton,this._createDisplayFuns[e.dataKey_Image]=this.createImage,this._createDisplayFuns[e.dataKey_Scale9]=this.createS9Image,this._createDisplayFuns[e.dataKey_ShapeImg]=this.createShapeImage,this._createDisplayFuns[e.dataKey_TextField]=this.createTextField,this.swfUpdateManager=t.SwfUpdateManager.createSwfUpdateManager(r)}return e.prototype.createSprite=function(n,r,i){void 0===r&&(r=null),void 0===i&&(i=null),null==i&&(i=this._swfData[e.dataKey_Sprite][n]);for(var s,a,o,l=new t.SwfSprite,h=i.length,u=0;h>u;u++)s=i[u],o=this._createDisplayFuns[s[1]],null!=o&&(a=o.apply(this,[s[0],s]),a.name=s[9],a.x=s[2],a.y=s[3],s[1]==e.dataKey_TextField&&(a.y+=6),s[1]!=e.dataKey_Scale9&&s[1]!=e.dataKey_ShapeImg&&(a.scaleX=s[4],a.scaleY=s[5]),a.skewX=s[6],a.skewY=s[7],a.alpha=s[8],l.addChild(a));return null!=r&&t.SwfBlendMode.setBlendMode(l,r[11]),l},e.prototype.createMovie=function(n,r){void 0===r&&(r=null);var i,s,a,o,l,h=this._swfData[e.dataKey_MovieClip][n],u=h.objCount,d={};for(l in u){s=u[l][0],a=u[l][1],i=null==d[l]?[]:d[l];for(var c=0;a>c;c++)o=this._createDisplayFuns[s],null!=o&&i.push(o.apply(this,[l,null]));d[l]=i}var p=new t.SwfMovieClip(h.frames,h.labels,d,this,h.frameEvents);return p.loop=h.loop,null!=r&&t.SwfBlendMode.setBlendMode(p,r[11]),p},e.prototype.createButton=function(n,r){void 0===r&&(r=null);var i=this._swfData[e.dataKey_Button][n],s=this.createSprite(null,null,i),a=new t.SwfButton(s);return a},e.prototype.createImage=function(n,r){void 0===r&&(r=null);var i=this._swfData[e.dataKey_Image][n],s=new egret.Bitmap;return s.texture=RES.getRes(n),s.anchorOffsetX=i[0],s.anchorOffsetY=i[1],null!=r&&t.SwfBlendMode.setBlendMode(s,r[11]),s},e.prototype.createS9Image=function(n,r){void 0===r&&(r=null);var i=this._swfData[e.dataKey_Scale9][n],s=new egret.Bitmap;return s.texture=RES.getRes(n),s.scale9Grid=new egret.Rectangle(i[0],i[1],i[2],i[3]),null!=r&&(s.width=r[10],s.height=r[11],t.SwfBlendMode.setBlendMode(s,r[13])),s},e.prototype.createShapeImage=function(e,n){void 0===n&&(n=null);var r=new egret.Bitmap;return r.texture=RES.getRes(e),r.fillMode=egret.BitmapFillMode.REPEAT,null!=n&&(r.width=n[10],r.height=n[11],t.SwfBlendMode.setBlendMode(r,n[13])),r},e.prototype.createTextField=function(e,n){void 0===n&&(n=null);var r=new egret.TextField;return null!=n&&(r.width=n[10],r.height=n[11],r.fontFamily=n[12],r.textColor=n[13],r.size=n[14],r.textAlign=n[15],r.text=n[18],this.createTextFieldFilter(r,n[19]),t.SwfBlendMode.setBlendMode(r,n[20])),r},e.prototype.createTextFieldFilter=function(t,e){for(var n in e)"flash.filters::GlowFilter"==n&&(t.stroke=e[n].strength,t.strokeColor=e[n].color)},e}();e.dataKey_Sprite="spr",e.dataKey_Image="img",e.dataKey_MovieClip="mc",e.dataKey_TextField="text",e.dataKey_Button="btn",e.dataKey_Scale9="s9",e.dataKey_ShapeImg="shapeImg",e.dataKey_Component="comp",e.dataKey_Particle="particle",t.Swf=e}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(e){function n(){var t=e.call(this)||this;return t._dataFormat=egret.HttpResponseType.TEXT,t}return __extends(n,e),n.prototype.analyzeData=function(e,n){var r=e.name;if(!this.fileDic[r]&&n)try{var i=n;this.fileDic[r]=new t.Swf(JSON.parse(i))}catch(s){egret.$warn(1017,e.url,n)}},n}(RES.BinAnalyzer);t.SwfAnalyzer=e}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(){function t(){}return t.createSwfUpdateManager=function(e){var n=new t;return n._animations=[],n._addQueue=[],n._removeQueue=[],n._currentTime=0,n.setFps(e),egret.Ticker.getInstance().register(n.update,n),n},t.prototype.setFps=function(t){this._fps=t,this._fpsTime=1e3/t},t.prototype.addSwfAnimation=function(t){this._addQueue.push(t)},t.prototype.removeSwfAnimation=function(t){this._removeQueue.push(t)},t.prototype.updateAdd=function(){for(var t,e,n=this._addQueue.length,r=0;n>r;r++)e=this._addQueue.pop(),t=this._animations.indexOf(e),-1==t&&this._animations.push(e)},t.prototype.updateRemove=function(){for(var t,e,n=this._removeQueue.length,r=0;n>r;r++)e=this._removeQueue.pop(),t=this._animations.indexOf(e),-1!=t&&this._animations.splice(t,1)},t.prototype.update=function(t){if(this._currentTime+=t,!(this._currentTimethis._fpsTime&&(this._currentTime=0),this.updateRemove(),this.updateAdd();for(var e,n=this._animations.length,r=0;n>r;r++)e=this._animations[r],null!=e.getStage()&&e.update()}},t}();t.SwfUpdateManager=e}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(){function t(){}return t.setBlendMode=function(e,n){t.modes[n]&&(e.blendMode=n)},t}();e.modes={normal:!0,add:!0},t.SwfBlendMode=e}(starlingswf||(starlingswf={}));var lzm;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.addEventListener(egret.Event.ADDED_TO_STAGE,e.addToStage,e),e.addEventListener(egret.Event.REMOVED_FROM_STAGE,e.removeFromStage,e),e}return __extends(e,t),e.prototype.addToStage=function(t){},e.prototype.removeFromStage=function(t){},e.prototype.gotoPanel=function(t){this.parent.addChild(t),this.dispose()},e.prototype.dispose=function(){null!=this.parent&&this.parent.removeChild(this),this.removeEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this),this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.removeFromStage,this)},e}(egret.DisplayObjectContainer);t.BasePanel=e}(lzm||(lzm={}));var starlingswf;!function(t){var e=function(e){function n(t){var n=e.call(this)||this;return n.defScale=-1,n.skin=t,n.addChild(t),n.touchEnabled=!0,n.addEventListener(egret.TouchEvent.TOUCH_BEGIN,n.mouseDown,n),n.addEventListener(egret.TouchEvent.TOUCH_END,n.mouseUp,n),n.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,n.mouseUp,n),n.addEventListener(egret.TouchEvent.TOUCH_TAP,n.mouseClick,n),n}return __extends(n,e),n.prototype.mouseDown=function(t){-1==this.defScale&&(this.defScale=this.scaleX),this.scaleX=.9*this.defScale,this.scaleY=.9*this.defScale},n.prototype.mouseUp=function(t){-1!=this.defScale&&(this.scaleX=this.defScale,this.scaleY=this.defScale)},n.prototype.mouseClick=function(e){this.dispatchEventWith(t.SwfButton.onClick)},n.prototype.setEnable=function(t){this.touchEnabled=t,t?this.alpha=1:this.alpha=.5},n.prototype.dispose=function(){this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.mouseDown,this),this.removeEventListener(egret.TouchEvent.TOUCH_END,this.mouseUp,this),this.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.mouseUp,this),this.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.mouseClick,this)},n}(t.SwfSprite);e.onClick="SwfButton.onClick",t.SwfButton=e}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(e){function n(t,n,r,i,s){void 0===s&&(s=null);var a=e.call(this)||this;return a._isPlay=!1,a.loop=!0,a._completeFunction=null,a._hasCompleteListener=!1,a._frames=t,a._labels=n,a._displayObjects=r,a._frameEvents=s,a._startFrame=0,a._endFrame=a._frames.length-1,a._ownerSwf=i,a.setCurrentFrame(0),a.play(),a}return __extends(n,e),n.prototype.getStage=function(){return this.visible?this.stage:null},n.prototype.update=function(){if(this._isPlay){if(this._currentFrame>=this._endFrame){var t=!1;if(this.loop&&this._startFrame!=this._endFrame||(this._ownerSwf&&this.stop(!1),t=!0),this._completeFunction&&this._completeFunction(this),this._hasCompleteListener&&this.dispatchEventWith(egret.Event.COMPLETE),t)return;this._currentFrame=this._startFrame}else this._currentFrame++;this.setCurrentFrame(this._currentFrame)}},n.prototype.setCurrentFrame=function(e){this.removeAllChilds(),this._currentFrame=e,this.__frameInfos=this._frames[this._currentFrame];for(var n,r,i,s,a=this.__frameInfos.length,o=0;a>o;o++){switch(n=this.__frameInfos[o],s=n[10],r=this._displayObjects[n[0]][s],r.$setSkewX(n[6]),r.$setSkewY(n[7]),r.$setAlpha(n[8]),r.name=n[9],r.$setX(n[2]),r.$setY(n[3]),n[1]){case t.Swf.dataKey_Scale9:r.width=n[11],r.height=n[12],t.SwfBlendMode.setBlendMode(r,n[13]);break;case t.Swf.dataKey_ShapeImg:r.width=n[11],r.height=n[12],t.SwfBlendMode.setBlendMode(r,n[13]);break;case t.Swf.dataKey_TextField:i=r,i.width=n[11],i.height=n[12],i.fontFamily=n[13],i.textColor=n[14],i.size=n[15],i.textAlign=n[16],n[19]&&"\r"!=n[19]&&""!=n[19]&&(i.text=n[19]),t.SwfBlendMode.setBlendMode(i,n[20]);break;default:r.$setScaleX(n[4]),r.$setScaleY(n[5]),t.SwfBlendMode.setBlendMode(r,n[11])}this.$doAddChild(r,a,!1)}null!=this._frameEvents&&null!=this._frameEvents[this._currentFrame]&&this.dispatchEventWith(this._frameEvents[this._currentFrame])},n.prototype.getCurrentFrame=function(){return this._currentFrame},n.prototype.play=function(){this._isPlay=!0,this._ownerSwf.swfUpdateManager.addSwfAnimation(this);var e,n,r;for(e in this._displayObjects)if(0==e.indexOf(t.Swf.dataKey_MovieClip)){n=this._displayObjects[e],r=n.length;for(var i=0;r>i;i++)n[i].play()}},n.prototype.stop=function(e){if(void 0===e&&(e=!0),this._isPlay=!1,this._ownerSwf.swfUpdateManager.removeSwfAnimation(this),e){var n,r,i;for(n in this._displayObjects)if(0==n.indexOf(t.Swf.dataKey_MovieClip)){r=this._displayObjects[n],i=r.length;for(var s=0;i>s;s++)r[s].stop(e)}}},n.prototype.gotoAndStop=function(t,e){void 0===e&&(e=!0),this.goTo(t),this.stop(e)},n.prototype.gotoAndPlay=function(t){this.goTo(t),this.play()},n.prototype.goTo=function(t){if("string"==typeof t){var e=this.getLabelData(t);this._currentLabel=e[0],this._currentFrame=this._startFrame=e[1],this._endFrame=e[2]}else"number"==typeof t&&(this._currentFrame=this._startFrame=t,this._endFrame=this._frames.length-1);this.setCurrentFrame(this._currentFrame)},n.prototype.getLabelData=function(t){for(var e,n=this._labels.length,r=0;n>r;r++)if(e=this._labels[r],e[0]==t)return e;return null},n.prototype.isPlay=function(){return this._isPlay},n.prototype.totalFrames=function(){return this._frames.length},n.prototype.currentLabel=function(){return this._currentLabel},n.prototype.labels=function(){for(var t=this._labels.length,e=[],n=0;t>n;n++)e.push(this._labels[n][0]);return e},n.prototype.hasLabel=function(t){var e=this.labels();return!(-1==e.indexOf(t))},n.prototype.addEventListener1=function(t,e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=0),this.addEventListener(t,e,n,r,i),this._hasCompleteListener=this.hasEventListener(egret.Event.COMPLETE)},n.prototype.removeEventListener1=function(t,e,n,r){void 0===r&&(r=!1),this.removeEventListener(t,e,n,r),this._hasCompleteListener=this.hasEventListener(egret.Event.COMPLETE)},n.prototype.removeAllChilds=function(){for(var t=this.$children,e=t.length-1;e>=0;e--)this.$doRemoveChild(e,!1)},n}(t.SwfSprite);t.SwfMovieClip=e}(starlingswf||(starlingswf={}));var lzm;!function(t){var e=function(){function e(){}return e.init=function(e){t.Alert.root=e,t.Alert.stageWidth=e.stageWidth,t.Alert.stageHeight=e.stageHeight},e.container=function(){return t.Alert.root},e.width=function(){return t.Alert.stageWidth},e.height=function(){return t.Alert.stageHeight},e.initBackGround=function(){null==t.Alert.background&&(t.Alert.background=new egret.Shape,t.Alert.background.graphics.beginFill(0),t.Alert.background.graphics.drawRect(0,0,t.Alert.stageWidth,t.Alert.stageHeight),t.Alert.background.graphics.endFill(),t.Alert.background.alpha=.5,t.Alert.background.touchEnabled=!0)},e.show=function(e){t.Alert.container().addChild(e)},e.alert=function(e,n){if(void 0===n&&(n=!0),-1==t.Alert.dialogs.indexOf(e)&&(e.addEventListener(egret.Event.ADDED_TO_STAGE,t.Alert.dialogAddToStage,e),t.Alert.initBackGround(),t.Alert.container().addChild(t.Alert.background),t.Alert.container().addChild(e),n)){var r=e.getBounds();e.x=(t.Alert.stageWidth-r.width)/2,e.y=(t.Alert.stageHeight-r.height)/2}},e.dialogAddToStage=function(e){var n=e.currentTarget;n.removeEventListener(egret.Event.ADDED_TO_STAGE,t.Alert.dialogAddToStage,n),n.addEventListener(egret.Event.REMOVED_FROM_STAGE,t.Alert.dialogRemoveFromStage,n),t.Alert.dialogs.push(n)},e.dialogRemoveFromStage=function(e){var n=e.currentTarget;n.removeEventListener(egret.Event.REMOVED_FROM_STAGE,t.Alert.dialogRemoveFromStage,n),t.Alert.dialogs.pop(),0==t.Alert.dialogs.length?t.Alert.container().removeChild(t.Alert.background):(n=t.Alert.dialogs[t.Alert.dialogs.length-1],t.Alert.container().swapChildren(t.Alert.background,n))},e}();e.dialogs=[],t.Alert=e}(lzm||(lzm={}));var lzm;!function(t){var e=function(){function e(){}return e.send=function(e,n,r,i,s){void 0===r&&(r=null),void 0===i&&(i=null),void 0===s&&(s="get");var a=new egret.HttpRequest,o=t.HttpClient.getRequestPars(n),l=function(t){a.removeEventListener(egret.Event.COMPLETE,l,a),a.removeEventListener(egret.IOErrorEvent.IO_ERROR,h,a),null!=r&&r(a.response)},h=function(t){a.removeEventListener(egret.Event.COMPLETE,l,a),a.removeEventListener(egret.IOErrorEvent.IO_ERROR,h,a),null!=i&&i(a.response)};a.addEventListener(egret.Event.COMPLETE,l,a),a.addEventListener(egret.IOErrorEvent.IO_ERROR,h,a),a.responseType=egret.HttpResponseType.TEXT,"get"==s?(a.open(e+"?"+o,egret.HttpMethod.GET),a.send()):"post"==s&&(a.open(e,egret.HttpMethod.POST),a.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),a.send(o))},e.getRequestPars=function(t){var e,n="";for(e in t)n+=e+"="+t[e]+"&";return n.substr(0,n.length-1)},e}();t.HttpClient=e}(lzm||(lzm={}));var lzm;!function(t){var e=function(){function t(t,e){this.isConnect=!1,this.host=t,this.port=e,this.socket=new egret.WebSocket,this.socket.addEventListener(egret.ProgressEvent.SOCKET_DATA,this.onReceiveMessage,this),this.socket.addEventListener(egret.Event.CONNECT,this.onSocketOpen,this),this.socket.addEventListener(egret.Event.CLOSE,this.onSocketClose,this),this.socket.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onSocketIOError,this)}return t.prototype.connect=function(){this.socket.connect(this.host,this.port)},t.prototype.sendData=function(t){this.socket.writeUTF(JSON.stringify(t))},t.prototype.onSocketOpen=function(){this.isConnect=!0,null!=this.onConnectCallBack&&this.onConnectCallBack()},t.prototype.onReceiveMessage=function(t){var e=this.socket.readUTF();null!=this.onDataCallBack&&this.onDataCallBack(JSON.parse(e))},t.prototype.onSocketClose=function(t){this.isConnect=!1,null!=this.onCloseCallBack&&this.onCloseCallBack()},t.prototype.onSocketIOError=function(t){null!=this.onIOErrorCallBack&&this.onIOErrorCallBack()},t.prototype.dispose=function(){this.socket.close(),this.onConnectCallBack=null,this.onIOErrorCallBack=null,this.onCloseCallBack=null,this.onDataCallBack=null},t}();t.JSONWebSocketClient=e}(lzm||(lzm={})); -------------------------------------------------------------------------------- /demo/libs/modules/tween/tween.min.js: -------------------------------------------------------------------------------- 1 | var __reflect=this&&this.__reflect||function(t,e,n){t.__class__=e,n?n.push(e):n=[e],t.__types__=t.__types__?n.concat(t.__types__):n},__extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)},egret;!function(t){var e=function(){function e(){t.$error(1014)}return e.get=function(t){return-1>t&&(t=-1),t>1&&(t=1),function(e){return 0==t?e:0>t?e*(e*-t+1+t):e*((2-e)*t+(1-t))}},e.getPowIn=function(t){return function(e){return Math.pow(e,t)}},e.getPowOut=function(t){return function(e){return 1-Math.pow(1-e,t)}},e.getPowInOut=function(t){return function(e){return(e*=2)<1?.5*Math.pow(e,t):1-.5*Math.abs(Math.pow(2-e,t))}},e.sineIn=function(t){return 1-Math.cos(t*Math.PI/2)},e.sineOut=function(t){return Math.sin(t*Math.PI/2)},e.sineInOut=function(t){return-.5*(Math.cos(Math.PI*t)-1)},e.getBackIn=function(t){return function(e){return e*e*((t+1)*e-t)}},e.getBackOut=function(t){return function(e){return--e*e*((t+1)*e+t)+1}},e.getBackInOut=function(t){return t*=1.525,function(e){return(e*=2)<1?.5*(e*e*((t+1)*e-t)):.5*((e-=2)*e*((t+1)*e+t)+2)}},e.circIn=function(t){return-(Math.sqrt(1-t*t)-1)},e.circOut=function(t){return Math.sqrt(1- --t*t)},e.circInOut=function(t){return(t*=2)<1?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)},e.bounceIn=function(t){return 1-e.bounceOut(1-t)},e.bounceOut=function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375},e.bounceInOut=function(t){return.5>t?.5*e.bounceIn(2*t):.5*e.bounceOut(2*t-1)+.5},e.getElasticIn=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var r=e/n*Math.asin(1/t);return-(t*Math.pow(2,10*(i-=1))*Math.sin((i-r)*n/e))}},e.getElasticOut=function(t,e){var n=2*Math.PI;return function(i){if(0==i||1==i)return i;var r=e/n*Math.asin(1/t);return t*Math.pow(2,-10*i)*Math.sin((i-r)*n/e)+1}},e.getElasticInOut=function(t,e){var n=2*Math.PI;return function(i){var r=e/n*Math.asin(1/t);return(i*=2)<1?-.5*(t*Math.pow(2,10*(i-=1))*Math.sin((i-r)*n/e)):t*Math.pow(2,-10*(i-=1))*Math.sin((i-r)*n/e)*.5+1}},e}();e.quadIn=e.getPowIn(2),e.quadOut=e.getPowOut(2),e.quadInOut=e.getPowInOut(2),e.cubicIn=e.getPowIn(3),e.cubicOut=e.getPowOut(3),e.cubicInOut=e.getPowInOut(3),e.quartIn=e.getPowIn(4),e.quartOut=e.getPowOut(4),e.quartInOut=e.getPowInOut(4),e.quintIn=e.getPowIn(5),e.quintOut=e.getPowOut(5),e.quintInOut=e.getPowInOut(5),e.backIn=e.getBackIn(1.7),e.backOut=e.getBackOut(1.7),e.backInOut=e.getBackInOut(1.7),e.elasticIn=e.getElasticIn(1,.3),e.elasticOut=e.getElasticOut(1,.3),e.elasticInOut=e.getElasticInOut(1,.3*1.5),t.Ease=e,__reflect(e.prototype,"egret.Ease")}(egret||(egret={}));var egret;!function(t){var e=function(e){function n(t,n,i){var r=e.call(this)||this;return r._target=null,r._useTicks=!1,r.ignoreGlobalPause=!1,r.loop=!1,r.pluginData=null,r._steps=null,r.paused=!1,r.duration=0,r._prevPos=-1,r.position=null,r._prevPosition=0,r._stepPosition=0,r.passive=!1,r.initialize(t,n,i),r}return __extends(n,e),n.get=function(t,e,i,r){return void 0===i&&(i=null),void 0===r&&(r=!1),r&&n.removeTweens(t),new n(t,e,i)},n.removeTweens=function(t){if(t.tween_count){for(var e=n._tweens,i=e.length-1;i>=0;i--)e[i]._target==t&&(e[i].paused=!0,e.splice(i,1));t.tween_count=0}},n.pauseTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!0)},n.resumeTweens=function(e){if(e.tween_count)for(var n=t.Tween._tweens,i=n.length-1;i>=0;i--)n[i]._target==e&&(n[i].paused=!1)},n.tick=function(t,e){void 0===e&&(e=!1);var i=t-n._lastTime;n._lastTime=t;for(var r=n._tweens.concat(),s=r.length-1;s>=0;s--){var o=r[s];e&&!o.ignoreGlobalPause||o.paused||o.$tick(o._useTicks?1:i)}return!1},n._register=function(e,i){var r=e._target,s=n._tweens;if(i)r&&(r.tween_count=r.tween_count>0?r.tween_count+1:1),s.push(e),n._inited||(n._lastTime=t.getTimer(),t.sys.$ticker.$startTick(n.tick,null),n._inited=!0);else{r&&r.tween_count--;for(var o=s.length;o--;)if(s[o]==e)return void s.splice(o,1)}},n.removeAllTweens=function(){for(var t=n._tweens,e=0,i=t.length;i>e;e++){var r=t[e];r.paused=!0,r._target.tweenjs_count=0}t.length=0},n.prototype.initialize=function(t,e,i){this._target=t,e&&(this._useTicks=e.useTicks,this.ignoreGlobalPause=e.ignoreGlobalPause,this.loop=e.loop,e.onChange&&this.addEventListener("change",e.onChange,e.onChangeObj),e.override&&n.removeTweens(t)),this.pluginData=i||{},this._curQueueProps={},this._initQueueProps={},this._steps=[],e&&e.paused?this.paused=!0:n._register(this,!0),e&&null!=e.position&&this.setPosition(e.position,n.NONE)},n.prototype.setPosition=function(t,e){void 0===e&&(e=1),0>t&&(t=0);var n=t,i=!1;if(n>=this.duration&&(this.loop?n%=this.duration:(n=this.duration,i=!0)),n==this._prevPos)return i;i&&this.setPaused(!0);var r=this._prevPos;if(this.position=this._prevPos=n,this._prevPosition=t,this._target&&this._steps.length>0){for(var s=this._steps.length,o=-1,u=0;s>u&&!("step"==this._steps[u].type&&(o=u,this._steps[u].t<=n&&this._steps[u].t+this._steps[u].d>=n));u++);for(var u=0;s>u;u++)if("action"==this._steps[u].type)0!=e&&(this._useTicks?this._runAction(this._steps[u],n,n):1==e&&r>n?(r!=this.duration&&this._runAction(this._steps[u],r,this.duration),this._runAction(this._steps[u],0,n,!0)):this._runAction(this._steps[u],r,n));else if("step"==this._steps[u].type&&o==u){var a=this._steps[o];this._updateTargetProps(a,Math.min((this._stepPosition=n-a.t)/a.d,1))}}return this.dispatchEventWith("change"),i},n.prototype._runAction=function(t,e,n,i){void 0===i&&(i=!1);var r=e,s=n;e>n&&(r=n,s=e);var o=t.t;(o==s||o>r&&s>o||i&&o==e)&&t.f.apply(t.o,t.p)},n.prototype._updateTargetProps=function(t,e){var i,r,s,o,u,a;if(t||1!=e){if(this.passive=!!t.v,this.passive)return;t.e&&(e=t.e(e,0,1,1)),i=t.p0,r=t.p1}else this.passive=!1,i=r=this._curQueueProps;for(var p in this._initQueueProps){null==(o=i[p])&&(i[p]=o=this._initQueueProps[p]),null==(u=r[p])&&(r[p]=u=o),s=o==u||0==e||1==e||"number"!=typeof o?1==e?u:o:o+(u-o)*e;var h=!1;if(a=n._plugins[p])for(var c=0,_=a.length;_>c;c++){var f=a[c].tween(this,p,s,i,r,e,!!t&&i==r,!t);f==n.IGNORE?h=!0:s=f}h||(this._target[p]=s)}},n.prototype.setPaused=function(t){return this.paused=t,n._register(this,!t),this},n.prototype._cloneProps=function(t){var e={};for(var n in t)e[n]=t[n];return e},n.prototype._addStep=function(t){return t.d>0&&(t.type="step",this._steps.push(t),t.t=this.duration,this.duration+=t.d),this},n.prototype._appendQueueProps=function(t){var e,i,r,s,o;for(var u in t)if(void 0===this._initQueueProps[u]){if(i=this._target[u],e=n._plugins[u])for(r=0,s=e.length;s>r;r++)i=e[r].init(this,u,i);this._initQueueProps[u]=this._curQueueProps[u]=void 0===i?null:i}else i=this._curQueueProps[u];for(var u in t){if(i=this._curQueueProps[u],e=n._plugins[u])for(o=o||{},r=0,s=e.length;s>r;r++)e[r].step&&e[r].step(this,u,i,t[u],o);this._curQueueProps[u]=t[u]}return o&&this._appendQueueProps(o),this._curQueueProps},n.prototype._addAction=function(t){return t.t=this.duration,t.type="action",this._steps.push(t),this},n.prototype._set=function(t,e){for(var n in t)e[n]=t[n]},n.prototype.wait=function(t,e){if(null==t||0>=t)return this;var n=this._cloneProps(this._curQueueProps);return this._addStep({d:t,p0:n,p1:n,v:e})},n.prototype.to=function(t,e,n){return void 0===n&&(n=void 0),(isNaN(e)||0>e)&&(e=0),this._addStep({d:e||0,p0:this._cloneProps(this._curQueueProps),e:n,p1:this._cloneProps(this._appendQueueProps(t))}),this.set(t)},n.prototype.call=function(t,e,n){return void 0===e&&(e=void 0),void 0===n&&(n=void 0),this._addAction({f:t,p:n?n:[],o:e?e:this._target})},n.prototype.set=function(t,e){return void 0===e&&(e=null),this._appendQueueProps(t),this._addAction({f:this._set,o:this,p:[t,e?e:this._target]})},n.prototype.play=function(t){return t||(t=this),this.call(t.setPaused,t,[!1])},n.prototype.pause=function(t){return t||(t=this),this.call(t.setPaused,t,[!0])},n.prototype.$tick=function(t){this.paused||this.setPosition(this._prevPosition+t)},n}(t.EventDispatcher);e.NONE=0,e.LOOP=1,e.REVERSE=2,e._tweens=[],e.IGNORE={},e._plugins={},e._inited=!1,e._lastTime=0,t.Tween=e,__reflect(e.prototype,"egret.Tween")}(egret||(egret={}));var egret;!function(t){var e;!function(e){function n(e){if("function"==typeof e)return e;var n=t.Ease[e];return"function"==typeof n?n:null}function i(t,e,n,i){var r=t.prototype;r.__meta__=r.__meta__||{},r.__meta__[e]=n,i&&(r.__defaultProperty__=e)}var r=function(t){function e(){var e=t.apply(this,arguments)||this;return e.name="",e}return __extends(e,t),e}(t.EventDispatcher);e.BasePath=r,__reflect(r.prototype,"egret.tween.BasePath");var s=function(t){function e(){var e=t.apply(this,arguments)||this;return e.props=void 0,e.duration=500,e.ease=void 0,e}return __extends(e,t),e}(r);e.To=s,__reflect(s.prototype,"egret.tween.To");var o=function(t){function e(){var e=t.apply(this,arguments)||this;return e.duration=500,e.passive=void 0,e}return __extends(e,t),e}(r);e.Wait=o,__reflect(o.prototype,"egret.tween.Wait");var u=function(t){function e(){var e=t.apply(this,arguments)||this;return e.props=void 0,e}return __extends(e,t),e}(r);e.Set=u,__reflect(u.prototype,"egret.tween.Set");var a=function(t){function e(){var e=t.apply(this,arguments)||this;return e.delta=0,e}return __extends(e,t),e}(r);e.Tick=a,__reflect(a.prototype,"egret.tween.Tick");var p=function(e){function i(){return e.call(this)||this}return __extends(i,e),Object.defineProperty(i.prototype,"props",{get:function(){return this._props},set:function(t){this._props=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(t){this._target=t},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"paths",{get:function(){return this._paths},set:function(t){this._paths=t||[]},enumerable:!0,configurable:!0}),i.prototype.play=function(t){this.tween?(this.tween.setPaused(!1),void 0!==t&&null!==t&&this.tween.setPosition(t)):this.createTween()},i.prototype.pause=function(){this.tween&&this.tween.setPaused(!0)},i.prototype.stop=function(){this.pause(),this.tween=null},i.prototype.createTween=function(){this.tween=t.Tween.get(this._target,this._props),this._paths&&this.applyPaths()},i.prototype.applyPaths=function(){for(var t=0;t=0&&e===this._paths.length-1&&this.dispatchEventWith("complete")},i}(t.EventDispatcher);e.TweenItem=p,__reflect(p.prototype,"egret.tween.TweenItem"),i(p,"paths","Array",!0);var h=function(t){function e(){var e=t.call(this)||this;return e.completeCount=0,e}return __extends(e,t),Object.defineProperty(e.prototype,"items",{get:function(){return this._items},set:function(t){this.completeCount=0,this.registerEvent(!1),this._items=t,this.registerEvent(!0)},enumerable:!0,configurable:!0}),e.prototype.registerEvent=function(t){var e=this;this._items&&this._items.forEach(function(n){t?n.addEventListener("complete",e.itemComplete,e):n.removeEventListener("complete",e.itemComplete,e)})},e.prototype.play=function(t){if(this._items)for(var e=0;eOpen-source,Free,Multi-platform", 3 | "Push Game Forward", 4 | "HTML5 Game Engine" 5 | ] -------------------------------------------------------------------------------- /demo/resource/default.res.json: -------------------------------------------------------------------------------- 1 | { 2 | "groups": [ 3 | { 4 | "keys": "bg_jpg,egret_icon_png,description_json,test_swf,test", 5 | "name": "preload" 6 | } 7 | ], 8 | "resources": [ 9 | { 10 | "url": "assets/bg.jpg", 11 | "type": "image", 12 | "name": "bg_jpg" 13 | }, 14 | { 15 | "url": "assets/egret_icon.png", 16 | "type": "image", 17 | "name": "egret_icon_png" 18 | }, 19 | { 20 | "url": "config/description.json", 21 | "type": "json", 22 | "name": "description_json" 23 | }, 24 | { 25 | "url": "assets/test_swf.json", 26 | "type": "swf", 27 | "name": "test_swf" 28 | }, 29 | { 30 | "url": "assets/test.json", 31 | "type": "sheet", 32 | "name": "test", 33 | "subkeys": "img_5,img_Tween 1,img_Tween_1,img_Zombie__imp_outerarm_lower,img_Zombie_balloon_body1,img_Zombie_balloon_body2,img_Zombie_balloon_bottom,img_Zombie_balloon_hat,img_Zombie_balloon_head,img_Zombie_balloon_innerarm_lower,img_Zombie_balloon_innerarm_upper,img_Zombie_balloon_innerleg_foot,img_Zombie_balloon_innerleg_lower,img_Zombie_balloon_innerleg_upper,img_Zombie_balloon_jaw,img_Zombie_balloon_outerarm_lower,img_Zombie_balloon_outerarm_upper,img_Zombie_balloon_outerarm_upper2,img_Zombie_balloon_outerleg_foot,img_Zombie_balloon_outerleg_lower,img_Zombie_balloon_outerleg_upper,img_Zombie_balloon_string,img_Zombie_balloon_top,img_Zombie_dolphinrider_body1,img_Zombie_dolphinrider_body2,img_Zombie_dolphinrider_dolphinbody1,img_Zombie_dolphinrider_dolphinbody2,img_Zombie_dolphinrider_dolphinfin1,img_Zombie_dolphinrider_dolphinfin2,img_Zombie_dolphinrider_dolphinjaw,img_Zombie_dolphinrider_head,img_Zombie_dolphinrider_innerarm_hand,img_Zombie_dolphinrider_innerarm_lower,img_Zombie_dolphinrider_innerarm_upper,img_Zombie_dolphinrider_innerleg_foot,img_Zombie_dolphinrider_innerleg_lower,img_Zombie_dolphinrider_innerleg_upper,img_Zombie_dolphinrider_jaw,img_Zombie_dolphinrider_outerarm_hand,img_Zombie_dolphinrider_outerarm_lower,img_Zombie_dolphinrider_outerarm_upper,img_Zombie_dolphinrider_outerarm_upper2,img_Zombie_dolphinrider_outerleg_foot1,img_Zombie_dolphinrider_outerleg_foot2,img_Zombie_dolphinrider_outerleg_lower,img_Zombie_dolphinrider_outerleg_upper,img_Zombie_gargantua_body1,img_Zombie_gargantua_body2,img_Zombie_gargantua_innerleg_upper,img_Zombie_gargantuar_head,img_Zombie_gargantuar_innerarm_hand,img_Zombie_gargantuar_innerarm_lower,img_Zombie_gargantuar_innerarm_upper,img_Zombie_gargantuar_innerleg_lower,img_Zombie_gargantuar_innlerleg_foot,img_Zombie_gargantuar_jaw,img_Zombie_gargantuar_outerarm_hand,img_Zombie_gargantuar_outerarm_lower,img_Zombie_gargantuar_outerarm_upper,img_Zombie_gargantuar_outerleg_foot,img_Zombie_gargantuar_outerleg_lower,img_Zombie_gargantuar_outerleg_upper,img_Zombie_gargantuar_telephonepole,img_Zombie_head,img_Zombie_imp_arm1_bone,img_Zombie_imp_body1,img_Zombie_imp_body2,img_Zombie_imp_head,img_Zombie_imp_innerarm_lower,img_Zombie_imp_innerarm_upper,img_Zombie_imp_innerleg_foot,img_Zombie_imp_innerleg_lower,img_Zombie_imp_innerleg_upper,img_Zombie_imp_jaw,img_Zombie_imp_outerarm upper,img_Zombie_imp_outerarm_lower,img_Zombie_imp_outerarm_upper,img_Zombie_imp_outerleg_foot,img_Zombie_imp_outerleg_lower,img_Zombie_imp_outerleg_upper,img_Zombie_innerarm_hand,img_Zombie_innerarm_hand1,img_Zombie_innerleg_foot,img_Zombie_innerleg_lower,img_Zombie_innerleg_upper,img_Zombie_jackbox_clownneck,img_Zombie_jaw,img_Zombie_outerarm_hand1,img_Zombie_outerarm_hand2,img_Zombie_polevaulter_body1,img_Zombie_polevaulter_body2,img_Zombie_polevaulter_hair,img_Zombie_polevaulter_innerarm_lower,img_Zombie_polevaulter_innerarm_upper,img_Zombie_polevaulter_innerhand,img_Zombie_polevaulter_innerleg_foot,img_Zombie_polevaulter_innerleg_lower,img_Zombie_polevaulter_innerleg_toe,img_Zombie_polevaulter_innerleg_upper,img_Zombie_polevaulter_outerarm_lower,img_Zombie_polevaulter_outerarm_upper,img_Zombie_polevaulter_outerarm_upper2,img_Zombie_polevaulter_outerleg_foot,img_Zombie_polevaulter_outerleg_lower,img_Zombie_polevaulter_outerleg_toe,img_Zombie_polevaulter_outerleg_upper,img_Zombie_polevaulter_pole,img_Zombie_polevaulter_pole2,img_Zombie_symbol_jackbox_INNERLEG_FOOT,img_Zombie_symbol_jackbox_body1,img_Zombie_symbol_jackbox_body2,img_Zombie_symbol_jackbox_box2,img_Zombie_symbol_jackbox_clownhead,img_Zombie_symbol_jackbox_handle,img_Zombie_symbol_jackbox_head,img_Zombie_symbol_jackbox_head2,img_Zombie_symbol_jackbox_innerarm_lower,img_Zombie_symbol_jackbox_innerarm_upper,img_Zombie_symbol_jackbox_innerleg_lower,img_Zombie_symbol_jackbox_innerleg_upper,img_Zombie_symbol_jackbox_jaw,img_Zombie_symbol_jackbox_outerarm_lower,img_Zombie_symbol_jackbox_outerarm_lower2,img_Zombie_symbol_jackbox_outerarm_upper,img_Zombie_symbol_jackbox_outerleg foot,img_Zombie_symbol_jackbox_outerleg_lower,img_Zombie_symbol_jackbox_outerleg_upper,img_Zombie_symbol_ladder_1,img_Zombie_symbol_ladder_3,img_Zombie_symbol_ladder_4,img_Zombie_symbol_ladder_5,img_Zombie_symbol_ladder_body,img_Zombie_symbol_ladder_hammer,img_Zombie_symbol_ladder_head,img_Zombie_symbol_ladder_innerarm_hand,img_Zombie_symbol_ladder_innerarm_hand2,img_Zombie_symbol_ladder_jaw,img_Zombie_symbol_ladder_leftarm_lower,img_Zombie_symbol_ladder_leftarm_upper,img_Zombie_symbol_ladder_leftfoot,img_Zombie_symbol_ladder_lower,img_Zombie_symbol_ladder_lowerbody1,img_Zombie_symbol_ladder_outerarm_hand,img_Zombie_symbol_ladder_outerarm_hand2,img_Zombie_symbol_ladder_outerarm_upper2,img_Zombie_symbol_ladder_outerhand,img_Zombie_symbol_ladder_rightarm_lower,img_Zombie_symbol_ladder_rightarm_upper,img_Zombie_symbol_ladder_rightfoot,img_Zombie_symbol_ladder_rightleg_upper,img_Zombie_symbol_ladder_upper,img_Zomby_symbol_ladder_2,img_big_test,img_btn_test,img_lajiao1,img_lajiao2,img_lajiao3,img_lajiao4,img_lajiao5,img_lajiaoshuzhi1,img_lajiaoye1,img_lajiaoye3,img_lajiaoye4,img_lajiaoye6,img_lajiaoye7,img_lajiaoyezi,img_mask_bird,img_particle,img_quad,img_shape36,img_skill_0,img_skill_1,img_skill_2,img_skill_3,img_skill_4,img_skill_5,img_skill_6,img_sprite189,img_sprite192,img_sprite195,img_sprite198,img_sprite201,img_sprite204,img_sprite207,img_sprite210,img_sprite213,img_sprite216,img_tudi,img_yingzi,s9_test1,s9_test2,s9_test3,s9_test4,shapeImg_dw" 34 | } 35 | ] 36 | } -------------------------------------------------------------------------------- /demo/src/LoadingUI.ts: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2014-present, Egret Technology. 4 | // All rights reserved. 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // * Neither the name of the Egret nor the 14 | // names of its contributors may be used to endorse or promote products 15 | // derived from this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 | // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, 23 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | ////////////////////////////////////////////////////////////////////////////////////// 29 | 30 | class LoadingUI extends egret.Sprite { 31 | 32 | public constructor() { 33 | super(); 34 | } 35 | 36 | private textField:egret.TextField; 37 | 38 | public createView():void { 39 | egret.log(this.stage); 40 | this.textField = new egret.TextField(); 41 | this.addChild(this.textField); 42 | this.textField.width = 480; 43 | this.textField.height = 100; 44 | this.textField.anchorOffsetX = 240; 45 | this.textField.anchorOffsetY = 50; 46 | this.textField.textAlign = "center"; 47 | egret.log(this.stage.stageWidth); 48 | this.textField.x = this.stage.stageWidth / 2;// - this.textField.width / 2; 49 | this.textField.y = this.stage.stageHeight / 2;// - this.textField.height / 2; 50 | } 51 | 52 | public setProgress(current:number, total:number):void { 53 | this.textField.text = `Loading...${current}/${total}`; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /demo/src/Main.ts: -------------------------------------------------------------------------------- 1 | ////////////////////////////////////////////////////////////////////////////////////// 2 | // 3 | // Copyright (c) 2014-present, Egret Technology. 4 | // All rights reserved. 5 | // Redistribution and use in source and binary forms, with or without 6 | // modification, are permitted provided that the following conditions are met: 7 | // 8 | // * Redistributions of source code must retain the above copyright 9 | // notice, this list of conditions and the following disclaimer. 10 | // * Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the 12 | // documentation and/or other materials provided with the distribution. 13 | // * Neither the name of the Egret nor the 14 | // names of its contributors may be used to endorse or promote products 15 | // derived from this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS 18 | // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 | // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 | // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 21 | // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, 23 | // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 24 | // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 25 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 | // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | // 28 | ////////////////////////////////////////////////////////////////////////////////////// 29 | 30 | class Main extends egret.DisplayObjectContainer { 31 | 32 | /** 33 | * 加载进度界面 34 | * Process interface loading 35 | */ 36 | private loadingView:LoadingUI; 37 | 38 | public constructor() { 39 | super(); 40 | this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); 41 | } 42 | 43 | private onAddToStage(event:egret.Event) { 44 | //设置加载进度界面 45 | //Config to load process interface 46 | this.loadingView = new LoadingUI(); 47 | this.stage.addChild(this.loadingView); 48 | this.loadingView.createView(); 49 | 50 | //初始化Resource资源加载库 51 | //initiate Resource loading library 52 | RES.registerAnalyzer("swf",starlingswf.SwfAnalyzer); 53 | RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); 54 | RES.loadConfig("resource/default.res.json", "resource/"); 55 | } 56 | 57 | /** 58 | * 配置文件加载完成,开始预加载preload资源组。 59 | * configuration file loading is completed, start to pre-load the preload resource group 60 | */ 61 | private onConfigComplete(event:RES.ResourceEvent):void { 62 | RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this); 63 | RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); 64 | RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this); 65 | RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); 66 | RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onItemLoadError, this); 67 | RES.loadGroup("preload"); 68 | } 69 | 70 | /** 71 | * preload资源组加载完成 72 | * Preload resource group is loaded 73 | */ 74 | private onResourceLoadComplete(event:RES.ResourceEvent):void { 75 | if (event.groupName == "preload") { 76 | this.stage.removeChild(this.loadingView); 77 | RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this); 78 | RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this); 79 | RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this); 80 | RES.removeEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onItemLoadError, this); 81 | this.createGameScene(); 82 | } 83 | } 84 | 85 | /** 86 | * 资源组加载出错 87 | * The resource group loading failed 88 | */ 89 | private onItemLoadError(event:RES.ResourceEvent):void { 90 | console.warn("Url:" + event.resItem.url + " has failed to load"); 91 | } 92 | 93 | /** 94 | * 资源组加载出错 95 | * The resource group loading failed 96 | */ 97 | private onResourceLoadError(event:RES.ResourceEvent):void { 98 | //TODO 99 | console.warn("Group:" + event.groupName + " has failed to load"); 100 | //忽略加载失败的项目 101 | //Ignore the loading failed projects 102 | this.onResourceLoadComplete(event); 103 | } 104 | 105 | /** 106 | * preload资源组加载进度 107 | * Loading process of preload resource group 108 | */ 109 | private onResourceProgress(event:RES.ResourceEvent):void { 110 | if (event.groupName == "preload") { 111 | this.loadingView.setProgress(event.itemsLoaded, event.itemsTotal); 112 | } 113 | } 114 | 115 | private textfield:egret.TextField; 116 | 117 | private swf:starlingswf.Swf; 118 | 119 | /** 120 | * 创建游戏场景 121 | * Create a game scene 122 | */ 123 | private createGameScene():void { 124 | var swfData:Object = RES.getRes("test_swf"); 125 | // this.swf = new starlingswf.Swf(swfData,this.stage.frameRate); 126 | this.swf = RES.getRes("test_swf"); 127 | this.swf.swfUpdateManager.setFps(this.stage.frameRate); 128 | this.test1(); 129 | 130 | // this.testAlert(); 131 | 132 | // this.testSocket(); 133 | 134 | // lzm.HttpClient.send("http://192.168.2.188/aptana/rings_server/test.php",{'a':123,"b":321},(data:string)=>{ 135 | // egret.log(data); 136 | // },null,'post'); 137 | } 138 | 139 | 140 | 141 | /** 142 | * Sprite测试 143 | * */ 144 | private test1():void{ 145 | var sprite:starlingswf.SwfSprite = this.swf.createSprite("spr_1"); 146 | this.addChild(sprite); 147 | } 148 | 149 | /** 150 | * MovieClip测试 151 | * */ 152 | private test2():void{ 153 | 154 | var mcNames:string[] = ["mc_lajiao","mc_test1","mc_Tain","mc_Zombie_balloon","mc_Zombie_dolphinrider","mc_Zombie_gargantuar","mc_Zombie_imp","mc_Zombie_jackbox","mc_Zombie_ladder","mc_Zombie_polevaulter"]; 155 | for(var i:number = 0 ; i < 50 ; i++){ 156 | var mcName:string = mcNames[Math.floor(Math.random() * mcNames.length)]; 157 | var mc:starlingswf.SwfMovieClip = this.swf.createMovie(mcName); 158 | mc.x = Math.random() * 480; 159 | mc.y = Math.random() * 320; 160 | this.addChild(mc); 161 | } 162 | 163 | } 164 | 165 | /** 166 | * 动画事件测试 167 | * */ 168 | private test3():void{ 169 | var mc:starlingswf.SwfMovieClip = this.swf.createMovie("mc_Tain"); 170 | mc.x = 480 / 2; 171 | mc.y = 320 / 2; 172 | mc.addEventListener(egret.Event.COMPLETE,this.mcComplete,mc); 173 | mc.gotoAndPlay("walk"); 174 | this.addChild(mc); 175 | } 176 | 177 | private mcComplete(e:egret.Event):void{ 178 | console.log("mcComplete"); 179 | } 180 | 181 | /** 182 | * 帧事件测试 183 | * */ 184 | private test4():void{ 185 | var mc:starlingswf.SwfMovieClip = this.swf.createMovie("mc_frame_event"); 186 | mc.addEventListener("@out",this.frameEventOut,mc); 187 | mc.addEventListener("@in",this.frameEventIn,mc); 188 | this.addChild(mc); 189 | } 190 | 191 | private frameEventOut(e:egret.Event):void{ 192 | egret.log("@out"); 193 | } 194 | 195 | private frameEventIn(e:egret.Event):void{ 196 | egret.log("@in"); 197 | } 198 | 199 | /** 200 | * blendMode 201 | * */ 202 | private test5(){ 203 | var spr:starlingswf.SwfSprite = this.swf.createSprite("spr_blendmode"); 204 | this.addChild(spr); 205 | } 206 | 207 | private testBtn(){ 208 | var btn:starlingswf.SwfButton = this.swf.createButton("btn_test1"); 209 | this.addChild(btn); 210 | 211 | btn.addEventListener(starlingswf.SwfButton.onClick,( evt:egret.Event )=>{ 212 | egret.log("onClick"); 213 | },this) 214 | } 215 | 216 | private testSocket(){ 217 | var socket:lzm.JSONWebSocketClient = new lzm.JSONWebSocketClient("127.0.0.1",8501); 218 | 219 | socket.onConnectCallBack = ()=>{ 220 | egret.log("链接成功"); 221 | socket.sendData({"a":"a","b":"b"}); 222 | } 223 | 224 | socket.onIOErrorCallBack = ()=>{ 225 | egret.log("链接失败"); 226 | } 227 | 228 | socket.onDataCallBack = (data:Object)=>{ 229 | egret.log(data); 230 | } 231 | 232 | socket.onCloseCallBack = ()=>{ 233 | egret.log("链接关闭"); 234 | } 235 | 236 | socket.connect(); 237 | } 238 | 239 | private testAlert(){ 240 | lzm.Alert.init(this.stage); 241 | 242 | var shape:egret.Shape = new egret.Shape(); 243 | shape.graphics.beginFill(0xff00ff); 244 | shape.graphics.drawRect(0,0,100,100); 245 | shape.graphics.endFill(); 246 | 247 | lzm.Alert.alert(shape); 248 | 249 | } 250 | } 251 | 252 | 253 | -------------------------------------------------------------------------------- /demo/template/runtime/native_loader.js: -------------------------------------------------------------------------------- 1 | require("launcher/native_require.js"); 2 | 3 | egret_native.egtMain = function () { 4 | egret_native.nativeType = "native"; 5 | 6 | egret_native.egretInit(); 7 | egret_native.egretStart(); 8 | }; 9 | -------------------------------------------------------------------------------- /demo/template/runtime/native_require.js: -------------------------------------------------------------------------------- 1 | 2 | var game_file_list = [ 3 | //以下为自动修改,请勿修改 4 | //----auto game_file_list start---- 5 | "libs/modules/egret/egret.js", 6 | "libs/modules/egret/egret.native.js", 7 | "libs/modules/game/game.js", 8 | "libs/modules/tween/tween.js", 9 | "libs/modules/res/res.js", 10 | "libs/modules/socket/socket.js", 11 | "libs/modules/starlingSwf/starlingSwf.js", 12 | "bin-debug/LoadingUI.js", 13 | "bin-debug/Main.js", 14 | //----auto game_file_list end---- 15 | ]; 16 | 17 | var window = this; 18 | 19 | egret_native.setSearchPaths([""]); 20 | 21 | egret_native.requireFiles = function () { 22 | for (var key in game_file_list) { 23 | var src = game_file_list[key]; 24 | require(src); 25 | } 26 | }; 27 | 28 | egret_native.egretInit = function () { 29 | if(egret_native.featureEnable) { 30 | //控制一些优化方案是否开启 31 | var result = egret_native.featureEnable({ 32 | 33 | }); 34 | } 35 | egret_native.requireFiles(); 36 | //egret.dom为空实现 37 | egret.dom = {}; 38 | egret.dom.drawAsCanvas = function () { 39 | }; 40 | }; 41 | 42 | egret_native.egretStart = function () { 43 | var option = { 44 | //以下为自动修改,请勿修改 45 | //----auto option start---- 46 | entryClassName: "Main", 47 | frameRate: 30, 48 | scaleMode: "noScale", 49 | contentWidth: 480, 50 | contentHeight: 320, 51 | showPaintRect: false, 52 | showFPS: false, 53 | fpsStyles: "x:0,y:0,size:12,textColor:0xffffff,bgAlpha:0.9", 54 | showLog: false, 55 | logFilter: "", 56 | maxTouches: 2, 57 | textureScaleFactor: 1 58 | //----auto option end---- 59 | }; 60 | 61 | egret.native.NativePlayer.option = option; 62 | egret.runEgret(); 63 | egret_native.Label.createLabel("/system/fonts/DroidSansFallback.ttf", 20, "", 0); 64 | egret_native.EGTView.preSetOffScreenBufferEnable(true); 65 | }; -------------------------------------------------------------------------------- /demo/template/runtime/runtime_loader.js: -------------------------------------------------------------------------------- 1 | require("launcher/native_require.js"); 2 | 3 | egret_native.egtMain = function () { 4 | egret_native.nativeType = "runtime"; 5 | 6 | egret_native.egretInit(); 7 | egret_native.egretStart(); 8 | }; -------------------------------------------------------------------------------- /demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "es5", 6 | "dom", 7 | "es2015.promise" 8 | ] 9 | }, 10 | "exclude": [ 11 | "node_modules" 12 | ] 13 | } -------------------------------------------------------------------------------- /demo/wingProperties.json: -------------------------------------------------------------------------------- 1 | { 2 | "close":false, 3 | "natures":["egretProject"], 4 | "resourcePlugin":{ 5 | "configs":[{ 6 | "configPath":"resource/default.res.json", 7 | "relativePath":"resource/" 8 | }], 9 | "id":"org.egret-labs.resource", 10 | "library":{ 11 | "children":[ 12 | { 13 | "isFolder":false, 14 | "key":"bg_jpg", 15 | "name":"bg_jpg" 16 | }, 17 | { 18 | "isFolder":false, 19 | "key":"egret_icon_png", 20 | "name":"egret_icon_png" 21 | } 22 | ] 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /libsrc/bin/starlingSwf/starlingSwf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | declare module starlingswf { 5 | /**Sprite*/ 6 | class SwfSprite extends egret.DisplayObjectContainer { 7 | getTextField(name: string): egret.TextField; 8 | getMovie(name: string): starlingswf.SwfMovieClip; 9 | getSprite(name: string): starlingswf.SwfSprite; 10 | getImage(name: string): egret.Bitmap; 11 | getButton(name: string): starlingswf.SwfButton; 12 | } 13 | } 14 | /** 15 | * Created by zmliu on 14-5-11. 16 | */ 17 | declare module starlingswf { 18 | /** 19 | * 动画接口 20 | * */ 21 | interface ISwfAnimation { 22 | update(): void; 23 | getStage(): egret.Stage; 24 | } 25 | } 26 | /** 27 | * Created by zmliu on 14-5-11. 28 | */ 29 | declare module starlingswf { 30 | /** 31 | * Swf文档类 32 | * */ 33 | class Swf { 34 | static dataKey_Sprite: string; 35 | static dataKey_Image: string; 36 | static dataKey_MovieClip: string; 37 | static dataKey_TextField: string; 38 | static dataKey_Button: string; 39 | static dataKey_Scale9: string; 40 | static dataKey_ShapeImg: string; 41 | static dataKey_Component: string; 42 | static dataKey_Particle: string; 43 | private _createDisplayFuns; 44 | private _swfData; 45 | swfUpdateManager: starlingswf.SwfUpdateManager; 46 | constructor(swfData: Object, fps?: number); 47 | createSprite(name: string, data?: any[], sprData?: any[]): starlingswf.SwfSprite; 48 | createMovie(name: string, data?: any[]): starlingswf.SwfMovieClip; 49 | /** 50 | * 创建按钮 51 | * */ 52 | createButton(name: string, data?: any[]): starlingswf.SwfButton; 53 | createImage(name: string, data?: any[]): egret.Bitmap; 54 | createS9Image(name: string, data?: any[]): egret.Bitmap; 55 | createShapeImage(name: string, data?: any[]): egret.Bitmap; 56 | createTextField(name: String, data?: any[]): egret.TextField; 57 | /** 创建文本的滤镜 */ 58 | createTextFieldFilter(textField: egret.TextField, filterObjects: Object): void; 59 | } 60 | } 61 | declare module starlingswf { 62 | class SwfAnalyzer extends RES.BinAnalyzer { 63 | constructor(); 64 | /** 65 | * 解析并缓存加载成功的数据 66 | */ 67 | analyzeData(resItem: RES.ResourceItem, data: any): void; 68 | } 69 | } 70 | /** 71 | * Created by zmliu on 14-5-11. 72 | */ 73 | declare module starlingswf { 74 | /** 动画更新管理器 */ 75 | class SwfUpdateManager { 76 | private _animations; 77 | private _addQueue; 78 | private _removeQueue; 79 | private _fps; 80 | private _fpsTime; 81 | private _currentTime; 82 | static createSwfUpdateManager(fps: number): SwfUpdateManager; 83 | setFps(fps: number): void; 84 | addSwfAnimation(animation: starlingswf.ISwfAnimation): void; 85 | removeSwfAnimation(animation: starlingswf.ISwfAnimation): void; 86 | private updateAdd(); 87 | private updateRemove(); 88 | private update(time); 89 | } 90 | } 91 | /** 92 | * Created by zmliu on 14-9-25. 93 | */ 94 | declare module starlingswf { 95 | class SwfBlendMode { 96 | static modes: Object; 97 | static setBlendMode(display: egret.DisplayObject, blendMode: string): void; 98 | } 99 | } 100 | declare module lzm { 101 | class BasePanel extends egret.DisplayObjectContainer { 102 | constructor(); 103 | addToStage(e: egret.Event): void; 104 | removeFromStage(e: egret.Event): void; 105 | gotoPanel(panel: lzm.BasePanel): void; 106 | dispose(): void; 107 | } 108 | } 109 | declare module starlingswf { 110 | class SwfButton extends starlingswf.SwfSprite { 111 | static onClick: string; 112 | static defSound: egret.Sound; 113 | skin: egret.DisplayObject; 114 | defScale: number; 115 | private _w; 116 | private _h; 117 | constructor(skin: egret.DisplayObject); 118 | mouseDown(evt: egret.TouchEvent): void; 119 | mouseUp(evt: egret.TouchEvent): void; 120 | mouseClick(evt: egret.TouchEvent): void; 121 | setEnable(val: boolean): void; 122 | dispose(): void; 123 | } 124 | } 125 | /** 126 | * Created by zmliu on 14-5-11. 127 | */ 128 | declare module starlingswf { 129 | class SwfMovieClip extends starlingswf.SwfSprite implements starlingswf.ISwfAnimation { 130 | private _ownerSwf; 131 | private _frames; 132 | private _labels; 133 | private _frameEvents; 134 | private _displayObjects; 135 | private _startFrame; 136 | private _endFrame; 137 | private _currentFrame; 138 | private _currentLabel; 139 | private _isPlay; 140 | loop: boolean; 141 | private _completeFunction; 142 | private _hasCompleteListener; 143 | constructor(frames: any[], labels: any[], displayObjects: Object, ownerSwf: starlingswf.Swf, frameEvents?: Object); 144 | getStage(): egret.Stage; 145 | update(): void; 146 | private __frameInfos; 147 | setCurrentFrame(frame: number): void; 148 | getCurrentFrame(): number; 149 | /** 150 | * 播放 151 | * */ 152 | play(): void; 153 | /** 154 | * 停止 155 | * @param stopChild 是否停止子动画 156 | * */ 157 | stop(stopChild?: boolean): void; 158 | gotoAndStop(frame: Object, stopChild?: boolean): void; 159 | gotoAndPlay(frame: Object): void; 160 | private goTo(frame); 161 | private getLabelData(label); 162 | /** 163 | * 是否再播放 164 | * */ 165 | isPlay(): boolean; 166 | /** 167 | * 总共有多少帧 168 | * */ 169 | totalFrames(): number; 170 | /** 171 | * 返回当前播放的是哪一个标签 172 | * */ 173 | currentLabel(): string; 174 | /** 175 | * 获取所有标签 176 | * */ 177 | labels(): any[]; 178 | /** 179 | * 是否包含某个标签 180 | * */ 181 | hasLabel(label: String): Boolean; 182 | addEventListener1(type: string, listener: Function, thisObject: any, useCapture?: boolean, priority?: number): void; 183 | removeEventListener1(type: string, listener: Function, thisObject: any, useCapture?: boolean): void; 184 | private removeAllChilds(); 185 | } 186 | } 187 | declare module lzm { 188 | class Alert { 189 | private static background; 190 | private static dialogs; 191 | private static root; 192 | private static stageWidth; 193 | private static stageHeight; 194 | private static alertScale; 195 | private static landscapeRotation; 196 | static init(root: egret.DisplayObjectContainer, stageWidth: number, stageHeight: number, alertScale?: number, landscapeRotation?: number): void; 197 | private static container(); 198 | private static width(); 199 | private static height(); 200 | private static initBackGround(); 201 | static show(display: egret.DisplayObject): void; 202 | static alertLandscape(display: egret.DisplayObject): void; 203 | static alert(dialog: egret.DisplayObject, setXY?: boolean): void; 204 | private static dialogAddToStage(e); 205 | private static dialogRemoveFromStage(e); 206 | static closeAllAlert(): void; 207 | } 208 | } 209 | declare module lzm { 210 | class HttpClient { 211 | /** 212 | * 请求url 213 | */ 214 | static send(url: string, params: Object, completeFunction?: Function, timeoutFunction?: Function, method?: String): void; 215 | static getRequestPars(params: Object): string; 216 | } 217 | } 218 | declare module lzm { 219 | class JSONWebSocketClient { 220 | private socket; 221 | private host; 222 | private port; 223 | isConnect: boolean; 224 | onConnectCallBack: Function; 225 | onIOErrorCallBack: Function; 226 | onCloseCallBack: Function; 227 | onDataCallBack: Function; 228 | constructor(host: string, port: number); 229 | connect(): void; 230 | sendData(data: Object): void; 231 | private onSocketOpen(); 232 | private onReceiveMessage(e); 233 | private onSocketClose(e); 234 | private onSocketIOError(e); 235 | dispose(): void; 236 | } 237 | } 238 | -------------------------------------------------------------------------------- /libsrc/bin/starlingSwf/starlingSwf.min.js: -------------------------------------------------------------------------------- 1 | var __reflect=this&&this.__reflect||function(t,e,n){t.__class__=e,n?n.push(e):n=[e],t.__types__=t.__types__?n.concat(t.__types__):n},__extends=this&&this.__extends||function(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);n.prototype=e.prototype,t.prototype=new n},starlingswf;!function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return __extends(e,t),e.prototype.getTextField=function(t){return this.getChildByName(t)},e.prototype.getMovie=function(t){return this.getChildByName(t)},e.prototype.getSprite=function(t){return this.getChildByName(t)},e.prototype.getImage=function(t){return this.getChildByName(t)},e.prototype.getButton=function(t){return this.getChildByName(t)},e}(egret.DisplayObjectContainer);t.SwfSprite=e,__reflect(e.prototype,"starlingswf.SwfSprite")}(starlingswf||(starlingswf={}));var lzm;!function(t){var e=function(){function t(t,e){this.isConnect=!1,this.host=t,this.port=e,this.socket=new egret.WebSocket,this.socket.addEventListener(egret.ProgressEvent.SOCKET_DATA,this.onReceiveMessage,this),this.socket.addEventListener(egret.Event.CONNECT,this.onSocketOpen,this),this.socket.addEventListener(egret.Event.CLOSE,this.onSocketClose,this),this.socket.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onSocketIOError,this)}return t.prototype.connect=function(){this.socket.connect(this.host,this.port)},t.prototype.sendData=function(t){this.socket.writeUTF(JSON.stringify(t))},t.prototype.onSocketOpen=function(){this.isConnect=!0,null!=this.onConnectCallBack&&this.onConnectCallBack()},t.prototype.onReceiveMessage=function(t){var e=this.socket.readUTF();null!=this.onDataCallBack&&this.onDataCallBack(JSON.parse(e))},t.prototype.onSocketClose=function(t){this.isConnect=!1,null!=this.onCloseCallBack&&this.onCloseCallBack()},t.prototype.onSocketIOError=function(t){null!=this.onIOErrorCallBack&&this.onIOErrorCallBack()},t.prototype.dispose=function(){this.socket.close(),this.onConnectCallBack=null,this.onIOErrorCallBack=null,this.onCloseCallBack=null,this.onDataCallBack=null},t}();t.JSONWebSocketClient=e,__reflect(e.prototype,"lzm.JSONWebSocketClient")}(lzm||(lzm={}));var starlingswf;!function(t){var e=function(){function e(n,r){void 0===r&&(r=24),this._swfData=n,this._createDisplayFuns=new Object,this._createDisplayFuns[e.dataKey_Sprite]=this.createSprite,this._createDisplayFuns[e.dataKey_MovieClip]=this.createMovie,this._createDisplayFuns[e.dataKey_Button]=this.createButton,this._createDisplayFuns[e.dataKey_Image]=this.createImage,this._createDisplayFuns[e.dataKey_Scale9]=this.createS9Image,this._createDisplayFuns[e.dataKey_ShapeImg]=this.createShapeImage,this._createDisplayFuns[e.dataKey_TextField]=this.createTextField,this.swfUpdateManager=t.SwfUpdateManager.createSwfUpdateManager(r)}return e.prototype.createSprite=function(n,r,i){void 0===r&&(r=null),void 0===i&&(i=null),null==i&&(i=this._swfData[e.dataKey_Sprite][n]);for(var o,s,a,l=new t.SwfSprite,h=i.length,c=0;h>c;c++)o=i[c],a=this._createDisplayFuns[o[1]],null!=a&&(s=a.apply(this,[o[0],o]),s.name=o[9],s.x=o[2],s.y=o[3],o[1]==e.dataKey_TextField&&(s.y+=6),o[1]!=e.dataKey_Scale9&&o[1]!=e.dataKey_ShapeImg&&(s.scaleX=o[4],s.scaleY=o[5]),s.skewX=o[6],s.skewY=o[7],s.alpha=o[8],l.addChild(s));return null!=r&&t.SwfBlendMode.setBlendMode(l,r[11]),l},e.prototype.createMovie=function(n,r){void 0===r&&(r=null);var i,o,s,a,l,h=this._swfData[e.dataKey_MovieClip][n],c=h.objCount,u={};for(l in c){o=c[l][0],s=c[l][1],i=null==u[l]?[]:u[l];for(var d=0;s>d;d++)a=this._createDisplayFuns[o],null!=a&&i.push(a.apply(this,[l,null]));u[l]=i}var p=new t.SwfMovieClip(h.frames,h.labels,u,this,h.frameEvents);return p.loop=h.loop,null!=r&&t.SwfBlendMode.setBlendMode(p,r[11]),p},e.prototype.createButton=function(n,r){void 0===r&&(r=null);var i=this._swfData[e.dataKey_Button][n],o=this.createSprite(null,null,i),s=new t.SwfButton(o);return s},e.prototype.createImage=function(n,r){void 0===r&&(r=null);var i=this._swfData[e.dataKey_Image][n],o=new egret.Bitmap;return o.texture=RES.getRes(n),o.anchorOffsetX=i[0],o.anchorOffsetY=i[1],null!=r&&t.SwfBlendMode.setBlendMode(o,r[11]),o},e.prototype.createS9Image=function(n,r){void 0===r&&(r=null);var i=this._swfData[e.dataKey_Scale9][n],o=new egret.Bitmap;return o.texture=RES.getRes(n),o.scale9Grid=new egret.Rectangle(i[0],i[1],i[2],i[3]),null!=r&&(o.width=r[10],o.height=r[11],t.SwfBlendMode.setBlendMode(o,r[13])),o},e.prototype.createShapeImage=function(e,n){void 0===n&&(n=null);var r=new egret.Bitmap;return r.texture=RES.getRes(e),r.fillMode=egret.BitmapFillMode.REPEAT,null!=n&&(r.width=n[10],r.height=n[11],t.SwfBlendMode.setBlendMode(r,n[13])),r},e.prototype.createTextField=function(e,n){void 0===n&&(n=null);var r=new egret.TextField;return null!=n&&(r.width=n[10],r.height=n[11],r.fontFamily=n[12],r.textColor=n[13],r.size=n[14],r.textAlign=n[15],r.text=n[18],this.createTextFieldFilter(r,n[19]),t.SwfBlendMode.setBlendMode(r,n[20])),r},e.prototype.createTextFieldFilter=function(t,e){for(var n in e)"flash.filters::GlowFilter"==n&&(t.stroke=e[n].strength,t.strokeColor=e[n].color)},e.dataKey_Sprite="spr",e.dataKey_Image="img",e.dataKey_MovieClip="mc",e.dataKey_TextField="text",e.dataKey_Button="btn",e.dataKey_Scale9="s9",e.dataKey_ShapeImg="shapeImg",e.dataKey_Component="comp",e.dataKey_Particle="particle",e}();t.Swf=e,__reflect(e.prototype,"starlingswf.Swf")}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(e){function n(){var t=e.call(this)||this;return t._dataFormat=egret.HttpResponseType.TEXT,t}return __extends(n,e),n.prototype.analyzeData=function(e,n){var r=e.name;if(!this.fileDic[r]&&n)try{var i=n;this.fileDic[r]=new t.Swf(JSON.parse(i),30)}catch(o){egret.$warn(1017,e.url,n)}},n}(RES.BinAnalyzer);t.SwfAnalyzer=e,__reflect(e.prototype,"starlingswf.SwfAnalyzer")}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(){function t(){}return t.createSwfUpdateManager=function(e){var n=new t;return n._animations=[],n._addQueue=[],n._removeQueue=[],n._currentTime=0,n.setFps(e),egret.Ticker.getInstance().register(n.update,n),n},t.prototype.setFps=function(t){this._fps=t,this._fpsTime=1e3/t},t.prototype.addSwfAnimation=function(t){this._addQueue.push(t)},t.prototype.removeSwfAnimation=function(t){this._removeQueue.push(t)},t.prototype.updateAdd=function(){for(var t,e,n=this._addQueue.length,r=0;n>r;r++)e=this._addQueue.pop(),t=this._animations.indexOf(e),-1==t&&this._animations.push(e)},t.prototype.updateRemove=function(){for(var t,e,n=this._removeQueue.length,r=0;n>r;r++)e=this._removeQueue.pop(),t=this._animations.indexOf(e),-1!=t&&this._animations.splice(t,1)},t.prototype.update=function(t){if(this._currentTime+=t,!(this._currentTimethis._fpsTime&&(this._currentTime=0),this.updateRemove(),this.updateAdd();for(var e,n=this._animations.length,r=0;n>r;r++)e=this._animations[r],null!=e.getStage()&&e.update()}},t}();t.SwfUpdateManager=e,__reflect(e.prototype,"starlingswf.SwfUpdateManager")}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(){function t(){}return t.setBlendMode=function(e,n){t.modes[n]&&(e.blendMode=n)},t.modes={normal:!0,add:!0},t}();t.SwfBlendMode=e,__reflect(e.prototype,"starlingswf.SwfBlendMode")}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(e){function n(t){var n=e.call(this)||this;return n.defScale=-1,n.skin=t,n._w=n.skin.width,n._h=n.skin.height,n.addChild(t),n.touchEnabled=!0,n.addEventListener(egret.TouchEvent.TOUCH_BEGIN,n.mouseDown,n),n.addEventListener(egret.TouchEvent.TOUCH_END,n.mouseUp,n),n.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,n.mouseUp,n),n.addEventListener(egret.TouchEvent.TOUCH_TAP,n.mouseClick,n),n}return __extends(n,e),n.prototype.mouseDown=function(t){this.skin.scaleX=1.1,this.skin.scaleY=1.1,this.skin.x=(1-1.1)/2*this._w,this.skin.y=(1-1.1)/2*this._h},n.prototype.mouseUp=function(t){this.skin.scaleX=1,this.skin.scaleY=1,this.skin.x=this.skin.y=0},n.prototype.mouseClick=function(e){this.dispatchEventWith(t.SwfButton.onClick),null!=n.defSound&&n.defSound.play(0,1)},n.prototype.setEnable=function(t){if(this.touchEnabled=t,t)this.filters=null;else{var e=[.3,.6,0,0,0,.3,.6,0,0,0,.3,.6,0,0,0,0,0,0,1,0],n=new egret.ColorMatrixFilter(e);this.filters=[n]}},n.prototype.dispose=function(){this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.mouseDown,this),this.removeEventListener(egret.TouchEvent.TOUCH_END,this.mouseUp,this),this.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.mouseUp,this),this.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.mouseClick,this)},n.onClick="SwfButton.onClick",n}(t.SwfSprite);t.SwfButton=e,__reflect(e.prototype,"starlingswf.SwfButton")}(starlingswf||(starlingswf={}));var starlingswf;!function(t){var e=function(e){function n(t,n,r,i,o){void 0===o&&(o=null);var s=e.call(this)||this;return s._isPlay=!1,s.loop=!0,s._completeFunction=null,s._hasCompleteListener=!1,s._frames=t,s._labels=n,s._displayObjects=r,s._frameEvents=o,s._startFrame=0,s._endFrame=s._frames.length-1,s._ownerSwf=i,s.setCurrentFrame(0),s.play(),s}return __extends(n,e),n.prototype.getStage=function(){return this.visible?this.stage:null},n.prototype.update=function(){if(this._isPlay){if(this._currentFrame>=this._endFrame){var t=!1;if(this.loop&&this._startFrame!=this._endFrame||(this._ownerSwf&&this.stop(!1),t=!0),this._completeFunction&&this._completeFunction(this),this._hasCompleteListener&&this.dispatchEventWith(egret.Event.COMPLETE),t)return;this._currentFrame=this._startFrame}else this._currentFrame++;this.setCurrentFrame(this._currentFrame)}},n.prototype.setCurrentFrame=function(e){this.removeAllChilds(),this._currentFrame=e,this.__frameInfos=this._frames[this._currentFrame];for(var n,r,i,o,s=this.__frameInfos.length,a=0;s>a;a++){switch(n=this.__frameInfos[a],o=n[10],r=this._displayObjects[n[0]][o],r.$setSkewX(n[6]),r.$setSkewY(n[7]),r.$setAlpha(n[8]),r.name=n[9],r.$setX(n[2]),r.$setY(n[3]),n[1]){case t.Swf.dataKey_Scale9:r.width=n[11],r.height=n[12],t.SwfBlendMode.setBlendMode(r,n[13]);break;case t.Swf.dataKey_ShapeImg:r.width=n[11],r.height=n[12],t.SwfBlendMode.setBlendMode(r,n[13]);break;case t.Swf.dataKey_TextField:i=r,i.width=n[11],i.height=n[12],i.fontFamily=n[13],i.textColor=n[14],i.size=n[15],i.textAlign=n[16],n[19]&&"\r"!=n[19]&&""!=n[19]&&(i.text=n[19]),t.SwfBlendMode.setBlendMode(i,n[20]);break;default:r.$setScaleX(n[4]),r.$setScaleY(n[5]),t.SwfBlendMode.setBlendMode(r,n[11])}this.$doAddChild(r,s,!1)}null!=this._frameEvents&&null!=this._frameEvents[this._currentFrame]&&this.dispatchEventWith(this._frameEvents[this._currentFrame])},n.prototype.getCurrentFrame=function(){return this._currentFrame},n.prototype.play=function(){this._isPlay=!0,this._ownerSwf.swfUpdateManager.addSwfAnimation(this);var e,n,r;for(e in this._displayObjects)if(0==e.indexOf(t.Swf.dataKey_MovieClip)){n=this._displayObjects[e],r=n.length;for(var i=0;r>i;i++)n[i].play()}},n.prototype.stop=function(e){if(void 0===e&&(e=!0),this._isPlay=!1,this._ownerSwf.swfUpdateManager.removeSwfAnimation(this),e){var n,r,i;for(n in this._displayObjects)if(0==n.indexOf(t.Swf.dataKey_MovieClip)){r=this._displayObjects[n],i=r.length;for(var o=0;i>o;o++)r[o].stop(e)}}},n.prototype.gotoAndStop=function(t,e){void 0===e&&(e=!0),this.goTo(t),this.stop(e)},n.prototype.gotoAndPlay=function(t){this.goTo(t),this.play()},n.prototype.goTo=function(t){if("string"==typeof t){var e=this.getLabelData(t);this._currentLabel=e[0],this._currentFrame=this._startFrame=e[1],this._endFrame=e[2]}else"number"==typeof t&&(this._currentFrame=this._startFrame=t,this._endFrame=this._frames.length-1);this.setCurrentFrame(this._currentFrame)},n.prototype.getLabelData=function(t){for(var e,n=this._labels.length,r=0;n>r;r++)if(e=this._labels[r],e[0]==t)return e;return null},n.prototype.isPlay=function(){return this._isPlay},n.prototype.totalFrames=function(){return this._frames.length},n.prototype.currentLabel=function(){return this._currentLabel},n.prototype.labels=function(){for(var t=this._labels.length,e=[],n=0;t>n;n++)e.push(this._labels[n][0]);return e},n.prototype.hasLabel=function(t){var e=this.labels();return!(-1==e.indexOf(t))},n.prototype.addEventListener1=function(t,e,n,r,i){void 0===r&&(r=!1),void 0===i&&(i=0),this.addEventListener(t,e,n,r,i),this._hasCompleteListener=this.hasEventListener(egret.Event.COMPLETE)},n.prototype.removeEventListener1=function(t,e,n,r){void 0===r&&(r=!1),this.removeEventListener(t,e,n,r),this._hasCompleteListener=this.hasEventListener(egret.Event.COMPLETE)},n.prototype.removeAllChilds=function(){for(var t=this.$children,e=t.length-1;e>=0;e--)this.$doRemoveChild(e,!1)},n}(t.SwfSprite);t.SwfMovieClip=e,__reflect(e.prototype,"starlingswf.SwfMovieClip",["starlingswf.ISwfAnimation"])}(starlingswf||(starlingswf={}));var lzm;!function(t){var e=function(){function e(){}return e.init=function(e,n,r,i,o){void 0===i&&(i=1),void 0===o&&(o=90),t.Alert.root=e,t.Alert.stageWidth=n,t.Alert.stageHeight=r,t.Alert.alertScale=i,t.Alert.landscapeRotation=o,t.Alert.initBackGround()},e.container=function(){return t.Alert.root},e.width=function(){return t.Alert.stageWidth},e.height=function(){return t.Alert.stageHeight},e.initBackGround=function(){null==t.Alert.background&&(t.Alert.background=new egret.Shape,t.Alert.background.alpha=.7,t.Alert.background.touchEnabled=!0),t.Alert.background.graphics.clear(),t.Alert.background.graphics.beginFill(0),t.Alert.background.graphics.drawRect(0,0,t.Alert.stageWidth,t.Alert.stageHeight),t.Alert.background.graphics.endFill()},e.show=function(e){t.Alert.container().addChild(e)},e.alertLandscape=function(e){t.Alert.alert(e),e.rotation=t.Alert.landscapeRotation},e.alert=function(e,n){void 0===n&&(n=!0),-1==t.Alert.dialogs.indexOf(e)&&(e.addEventListener(egret.Event.ADDED_TO_STAGE,t.Alert.dialogAddToStage,e),t.Alert.container().addChild(t.Alert.background),t.Alert.container().addChild(e),n&&(e.anchorOffsetX=e.width/2,e.anchorOffsetY=e.height/2,e.x=t.Alert.stageWidth/2,e.y=t.Alert.stageHeight/2),e.scaleX=e.scaleY=.1,egret.Tween.get(e).to({scaleX:t.Alert.alertScale,scaleY:t.Alert.alertScale},300,egret.Ease.backOut))},e.dialogAddToStage=function(e){var n=e.currentTarget;n.removeEventListener(egret.Event.ADDED_TO_STAGE,t.Alert.dialogAddToStage,n),n.addEventListener(egret.Event.REMOVED_FROM_STAGE,t.Alert.dialogRemoveFromStage,n),t.Alert.dialogs.push(n)},e.dialogRemoveFromStage=function(e){var n=e.currentTarget;if(n.removeEventListener(egret.Event.REMOVED_FROM_STAGE,t.Alert.dialogRemoveFromStage,n),t.Alert.dialogs.pop(),0==t.Alert.dialogs.length)t.Alert.background.parent==t.Alert.container()&&t.Alert.container().removeChild(t.Alert.background);else{for(;t.Alert.dialogs.length>0;){if(n=t.Alert.dialogs[t.Alert.dialogs.length-1],n.parent==t.Alert.container()){t.Alert.container().swapChildren(t.Alert.background,n);break}t.Alert.dialogs.pop()}0==t.Alert.dialogs.length&&t.Alert.background.parent==t.Alert.container()&&t.Alert.container().removeChild(t.Alert.background)}},e.closeAllAlert=function(){for(var t,n,r=e.dialogs.length,i=[],o=0;r>o;o++)i.push(e.dialogs[o]);for(var o=0;r>o;o++)t=i[o],n=t.dispose,n instanceof Function&&n.apply(t,[]),null!=t.parent&&t.parent.removeChild(t)},e.dialogs=[],e}();t.Alert=e,__reflect(e.prototype,"lzm.Alert")}(lzm||(lzm={}));var lzm;!function(t){var e=function(){function e(){}return e.send=function(e,n,r,i,o){void 0===r&&(r=null),void 0===i&&(i=null),void 0===o&&(o="get");var s=new egret.HttpRequest,a=t.HttpClient.getRequestPars(n),l=function(t){s.removeEventListener(egret.Event.COMPLETE,l,s),s.removeEventListener(egret.IOErrorEvent.IO_ERROR,h,s),null!=r&&r(s.response)},h=function(t){s.removeEventListener(egret.Event.COMPLETE,l,s),s.removeEventListener(egret.IOErrorEvent.IO_ERROR,h,s),null!=i&&i(s.response)};s.addEventListener(egret.Event.COMPLETE,l,s),s.addEventListener(egret.IOErrorEvent.IO_ERROR,h,s),s.responseType=egret.HttpResponseType.TEXT,"get"==o?(""!=a?s.open(e+"?"+a,egret.HttpMethod.GET):s.open(e,egret.HttpMethod.GET),s.send()):"post"==o&&(s.open(e,egret.HttpMethod.POST),s.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),s.send(a))},e.getRequestPars=function(t){var e,n="";for(e in t)n+=e+"="+t[e]+"&";return n.substr(0,n.length-1)},e}();t.HttpClient=e,__reflect(e.prototype,"lzm.HttpClient")}(lzm||(lzm={}));var lzm;!function(t){var e=function(t){function e(){var e=t.call(this)||this;return e.addEventListener(egret.Event.ADDED_TO_STAGE,e.addToStage,e),e.addEventListener(egret.Event.REMOVED_FROM_STAGE,e.removeFromStage,e),e}return __extends(e,t),e.prototype.addToStage=function(t){},e.prototype.removeFromStage=function(t){},e.prototype.gotoPanel=function(t){this.parent.addChild(t),this.dispose()},e.prototype.dispose=function(){null!=this.parent&&this.parent.removeChild(this),this.removeEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this),this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.removeFromStage,this)},e}(egret.DisplayObjectContainer);t.BasePanel=e,__reflect(e.prototype,"lzm.BasePanel")}(lzm||(lzm={})); -------------------------------------------------------------------------------- /libsrc/libs/socket.d.ts: -------------------------------------------------------------------------------- 1 | declare namespace egret { 2 | /** 3 | * @language en_US 4 | * @private 5 | * @version Egret 2.4 6 | * @platform Web,Native 7 | */ 8 | /** 9 | * @language zh_CN 10 | * @private 11 | * @version Egret 2.4 12 | * @platform Web,Native 13 | */ 14 | interface ISocket { 15 | /** 16 | * @language en_US 17 | * 连接 18 | * @method egret.ISocket#connect 19 | * @version Egret 2.4 20 | * @platform Web,Native 21 | */ 22 | /** 23 | * @language zh_CN 24 | * 连接 25 | * @method egret.ISocket#connect 26 | * @version Egret 2.4 27 | * @platform Web,Native 28 | */ 29 | connect(host: string, port: number): void; 30 | /** 31 | * 连接 32 | * @method egret.ISocket#connect 33 | */ 34 | connectByUrl(url: string): void; 35 | /** 36 | * @language en_US 37 | * 38 | * @param onConnect 39 | * @param onClose 40 | * @param onSocketData 41 | * @param onError 42 | * @param thisObject 43 | * @version Egret 2.4 44 | * @platform Web,Native 45 | */ 46 | /** 47 | * @language zh_CN 48 | * 49 | * @param onConnect 50 | * @param onClose 51 | * @param onSocketData 52 | * @param onError 53 | * @param thisObject 54 | * @version Egret 2.4 55 | * @platform Web,Native 56 | */ 57 | addCallBacks(onConnect: Function, onClose: Function, onSocketData: Function, onError: Function, thisObject: any): void; 58 | /** 59 | * @language en_US 60 | * 61 | * @param message 62 | * @version Egret 2.4 63 | * @platform Web,Native 64 | */ 65 | /** 66 | * @language zh_CN 67 | * 68 | * @param message 69 | * @version Egret 2.4 70 | * @platform Web,Native 71 | */ 72 | send(message: any): void; 73 | /** 74 | * @language en_US 75 | * 76 | * @version Egret 2.4 77 | * @platform Web,Native 78 | */ 79 | /** 80 | * @language zh_CN 81 | * 82 | * @version Egret 2.4 83 | * @platform Web,Native 84 | */ 85 | close(): void; 86 | } 87 | /** 88 | * @language en_US 89 | * @version Egret 2.4 90 | * @platform Web,Native 91 | */ 92 | /** 93 | * @language zh_CN 94 | * @version Egret 2.4 95 | * @platform Web,Native 96 | */ 97 | let ISocket: { 98 | new (): ISocket; 99 | }; 100 | } 101 | declare namespace egret { 102 | /** 103 | * @language en_US 104 | * The egret.WebSocket class enables code to establish a TCP socket connection, for sending and receiving character string or binary data. 105 | * To use the methods of the egret.WebSocket class, first use the constructor function new egret.WebSocket to create an egret.WebSocket object. 106 | * The socket transmits and receives data in asynchronous mode. 107 | * @event egret.Event.CONNECT Successfully connect to the server。 108 | * @event egret.ProgressEvent.SOCKET_DATA Receiving server data。 109 | * @event egret.Event.CLOSE Dispatched when the server closes the connection. 110 | * @event egret.ProgressEvent Dispatched when an IO error causes a send or load operation to fail. 111 | * @see http://edn.egret.com/cn/docs/page/602 WebSocket 112 | * @version Egret 2.4 113 | * @platform Web,Native 114 | * @includeExample extension/socket/WebSocket.ts 115 | */ 116 | /** 117 | * @language zh_CN 118 | * egret.WebSocket 类启用代码以建立传输控制协议 (TCP) 套接字连接,用于发送和接收字符串或二进制数据。 119 | * 要使用 egret.WebSocket 类的方法,请先使用构造函数 new egret.WebSocket 创建一个 egret.WebSocket 对象。 120 | * 套接字以异步方式传输和接收数据。 121 | * @event egret.Event.CONNECT 连接服务器成功。 122 | * @event egret.ProgressEvent.SOCKET_DATA 接收服务器数据。 123 | * @event egret.Event.CLOSE 在服务器关闭连接时调度。 124 | * @event egret.IOErrorEvent.IO_ERROR 在出现输入/输出错误并导致发送或加载操作失败时调度。。 125 | * @see http://edn.egret.com/cn/docs/page/602 WebSocket 126 | * @version Egret 2.4 127 | * @platform Web,Native 128 | * @includeExample extension/socket/WebSocket.ts 129 | */ 130 | class WebSocket extends egret.EventDispatcher { 131 | /** 132 | * @language en_US 133 | * Send and receive data in character string format 134 | * @version Egret 2.4 135 | * @platform Web,Native 136 | */ 137 | /** 138 | * @language zh_CN 139 | * 以字符串格式发送和接收数据 140 | * @version Egret 2.4 141 | * @platform Web,Native 142 | */ 143 | static TYPE_STRING: string; 144 | /** 145 | * @language en_US 146 | * Send and receive data in binary format 147 | * @version Egret 2.4 148 | * @platform Web,Native 149 | */ 150 | /** 151 | * @language zh_CN 152 | * 以二进制格式发送和接收数据 153 | * @version Egret 2.4 154 | * @platform Web,Native 155 | */ 156 | static TYPE_BINARY: string; 157 | /** 158 | * @private 159 | */ 160 | private socket; 161 | /** 162 | * @private 163 | */ 164 | private _writeMessage; 165 | /** 166 | * @private 167 | */ 168 | private _readMessage; 169 | /** 170 | * @private 171 | */ 172 | private _connected; 173 | /** 174 | * @private 175 | */ 176 | private _connecting; 177 | /** 178 | * @language en_US 179 | * Create an egret.WebSocket object 180 | * This parameter is reserved for later versions. The connection address and port number are imported in the connect function 181 | * @version Egret 2.4 182 | * @platform Web,Native 183 | */ 184 | /** 185 | * @language zh_CN 186 | * 创建一个 egret.WebSocket 对象 187 | * 参数为预留参数,现版本暂不处理,连接地址和端口号在 connect 函数中传入 188 | * @version Egret 2.4 189 | * @platform Web,Native 190 | */ 191 | constructor(host?: string, port?: number); 192 | /** 193 | * @language en_US 194 | * Connect the socket to the specified host and port number 195 | * @param host Name or IP address of the host to be connected 196 | * @param port Port number to be connected 197 | * @version Egret 2.4 198 | * @platform Web,Native 199 | */ 200 | /** 201 | * @language zh_CN 202 | * 将套接字连接到指定的主机和端口 203 | * @param host 要连接到的主机的名称或 IP 地址 204 | * @param port 要连接到的端口号 205 | * @version Egret 2.4 206 | * @platform Web,Native 207 | */ 208 | connect(host: string, port: number): void; 209 | /** 210 | * 根据提供的url连接 211 | * @param url 全地址。如ws://echo.websocket.org:80 212 | */ 213 | connectByUrl(url: string): void; 214 | /** 215 | * @language en_US 216 | * Closesocket 217 | * @version Egret 2.4 218 | * @platform Web,Native 219 | */ 220 | /** 221 | * @language zh_CN 222 | * 关闭套接字 223 | * @version Egret 2.4 224 | * @platform Web,Native 225 | */ 226 | close(): void; 227 | /** 228 | * @private 229 | * 230 | */ 231 | private onConnect(); 232 | /** 233 | * @private 234 | * 235 | */ 236 | private onClose(); 237 | /** 238 | * @private 239 | * 240 | */ 241 | private onError(); 242 | /** 243 | * @private 244 | * 245 | * @param message 246 | */ 247 | private onSocketData(message); 248 | /** 249 | * @language en_US 250 | * Refresh all data accumulated in the output buffer area of the socket 251 | * @version Egret 2.4 252 | * @platform Web,Native 253 | */ 254 | /** 255 | * @language zh_CN 256 | * 对套接字输出缓冲区中积累的所有数据进行刷新 257 | * @version Egret 2.4 258 | * @platform Web,Native 259 | */ 260 | flush(): void; 261 | /** 262 | * @private 263 | */ 264 | private _isReadySend; 265 | /** 266 | * @language en_US 267 | * Write data in character string in the socket 268 | * @param message The character string to be written in the socket 269 | * @version Egret 2.4 270 | * @platform Web,Native 271 | */ 272 | /** 273 | * @language zh_CN 274 | * 将字符串数据写入套接字 275 | * @param message 要写入套接字的字符串 276 | * @version Egret 2.4 277 | * @platform Web,Native 278 | */ 279 | writeUTF(message: string): void; 280 | /** 281 | * @language en_US 282 | * Read a UTF-8 character string from the socket 283 | * @returns {string} 284 | * @version Egret 2.4 285 | * @platform Web,Native 286 | */ 287 | /** 288 | * @language zh_CN 289 | * 从套接字读取一个 UTF-8 字符串 290 | * @returns {string} 291 | * @version Egret 2.4 292 | * @platform Web,Native 293 | */ 294 | readUTF(): string; 295 | /** 296 | * @private 297 | */ 298 | private _readByte; 299 | /** 300 | * @private 301 | */ 302 | private _writeByte; 303 | /** 304 | * @private 305 | */ 306 | private _bytesWrite; 307 | /** 308 | * @language en_US 309 | * Write a series of bytes from the specified byte array. The writing operation starts from the location expressed by offset. 310 | * If the length parameter is ignored, the default length 0 indicates that data is written from offset in the entire buffer area. 311 | * If the offset parameter is ignored, data is written in the entire buffer area. 312 | * @param bytes The ByteArray object where data is read from 313 | * @param offset Zero-based offset in the ByteArray object. From here start performing data writing 314 | * @param length Number of bytes to be written Default value 0 indicates data is written in the entire buffer area from the value specified by the offset parameter 315 | * @version Egret 2.4 316 | * @platform Web,Native 317 | */ 318 | /** 319 | * @language zh_CN 320 | * 从指定的字节数组写入一系列字节。写入操作从 offset 指定的位置开始。 321 | * 如果省略了 length 参数,则默认长度 0 将导致该方法从 offset 开始写入整个缓冲区。 322 | * 如果还省略了 offset 参数,则写入整个缓冲区。 323 | * @param bytes 要从中读取数据的 ByteArray 对象 324 | * @param offset ByteArray 对象中从零开始的偏移量,应由此开始执行数据写入 325 | * @param length 要写入的字节数。默认值 0 导致从 offset 参数指定的值开始写入整个缓冲区 326 | * @version Egret 2.4 327 | * @platform Web,Native 328 | */ 329 | writeBytes(bytes: ByteArray, offset?: number, length?: number): void; 330 | /** 331 | * @language en_US 332 | * Read data byte number specified by the length parameter from the socket. Read these bytes into the specified byte array starting from the location expressed by offset. 333 | * @param bytes The ByteArray object that data is read into 334 | * @param offset The offset for data reading starts from this byte array 335 | * @param length Byte number to be read Default value 0 indicates reading all available data 336 | * @version Egret 2.4 337 | * @platform Web,Native 338 | */ 339 | /** 340 | * @language zh_CN 341 | * 从套接字读取 length 参数指定的数据字节数。从 offset 所表示的位置开始,将这些字节读入指定的字节数组 342 | * @param bytes 要将数据读入的 ByteArray 对象 343 | * @param offset 数据读取的偏移量应从该字节数组中开始 344 | * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 345 | * @version Egret 2.4 346 | * @platform Web,Native 347 | */ 348 | readBytes(bytes: ByteArray, offset?: number, length?: number): void; 349 | /** 350 | * @language en_US 351 | * Indicates whether the Socket object is connected currently 352 | * @version Egret 2.4 353 | * @platform Web,Native 354 | */ 355 | /** 356 | * @language zh_CN 357 | * 表示此 Socket 对象目前是否已连接 358 | * @version Egret 2.4 359 | * @platform Web,Native 360 | */ 361 | connected: boolean; 362 | /** 363 | * @private 364 | */ 365 | private _type; 366 | /** 367 | * @language en_US 368 | * Format for sending and receiving data. The default setting is the character string format 369 | * @version Egret 2.4 370 | * @platform Web,Native 371 | */ 372 | /** 373 | * @language zh_CN 374 | * 发送和接收数据的格式,默认是字符串格式 375 | * @version Egret 2.4 376 | * @platform Web,Native 377 | */ 378 | type: string; 379 | } 380 | } 381 | declare namespace egret.native { 382 | /** 383 | * @private 384 | */ 385 | class NativeSocket implements ISocket { 386 | private socket; 387 | constructor(); 388 | private onConnect; 389 | private onClose; 390 | private onSocketData; 391 | private onError; 392 | private thisObject; 393 | addCallBacks(onConnect: Function, onClose: Function, onSocketData: Function, onError: Function, thisObject: any): void; 394 | private host; 395 | private port; 396 | connect(host: string, port: number): void; 397 | connectByUrl(url: string): void; 398 | private _bindEvent(); 399 | send(message: any): void; 400 | close(): void; 401 | } 402 | } 403 | declare namespace egret.web { 404 | /** 405 | * @private 406 | */ 407 | class HTML5WebSocket implements ISocket { 408 | private socket; 409 | constructor(); 410 | private onConnect; 411 | private onClose; 412 | private onSocketData; 413 | private onError; 414 | private thisObject; 415 | addCallBacks(onConnect: Function, onClose: Function, onSocketData: Function, onError: Function, thisObject: any): void; 416 | private host; 417 | private port; 418 | connect(host: string, port: number): void; 419 | connectByUrl(url: string): void; 420 | private _bindEvent(); 421 | send(message: any): void; 422 | close(): void; 423 | } 424 | } 425 | -------------------------------------------------------------------------------- /libsrc/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "starlingSwf" 3 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/display/Alert.ts: -------------------------------------------------------------------------------- 1 | module lzm { 2 | export class Alert { 3 | 4 | private static background:egret.Shape; 5 | private static dialogs:egret.DisplayObject[] = []; 6 | 7 | private static root:egret.DisplayObjectContainer; 8 | private static stageWidth:number; 9 | private static stageHeight:number; 10 | private static alertScale:number; 11 | private static landscapeRotation:number; 12 | 13 | public static init(root:egret.DisplayObjectContainer,stageWidth:number,stageHeight:number,alertScale:number = 1,landscapeRotation:number = 90):void{ 14 | lzm.Alert.root = root; 15 | lzm.Alert.stageWidth = stageWidth; 16 | lzm.Alert.stageHeight = stageHeight; 17 | lzm.Alert.alertScale = alertScale; 18 | lzm.Alert.landscapeRotation = landscapeRotation; 19 | lzm.Alert.initBackGround(); 20 | } 21 | 22 | private static container():egret.DisplayObjectContainer{ 23 | return lzm.Alert.root; 24 | } 25 | 26 | private static width():Number{ 27 | return lzm.Alert.stageWidth; 28 | } 29 | 30 | private static height():Number{ 31 | return lzm.Alert.stageHeight; 32 | } 33 | 34 | private static initBackGround():void{ 35 | if(lzm.Alert.background == null) { 36 | lzm.Alert.background = new egret.Shape(); 37 | lzm.Alert.background.alpha = 0.7; 38 | lzm.Alert.background.touchEnabled = true; 39 | } 40 | lzm.Alert.background.graphics.clear(); 41 | lzm.Alert.background.graphics.beginFill(0x000000); 42 | lzm.Alert.background.graphics.drawRect(0,0, lzm.Alert.stageWidth, lzm.Alert.stageHeight); 43 | lzm.Alert.background.graphics.endFill(); 44 | } 45 | 46 | public static show(display:egret.DisplayObject):void{ 47 | lzm.Alert.container().addChild(display); 48 | } 49 | 50 | public static alertLandscape(display:egret.DisplayObject):void{ 51 | lzm.Alert.alert(display); 52 | display.rotation = lzm.Alert.landscapeRotation; 53 | } 54 | 55 | public static alert(dialog:egret.DisplayObject,setXY:boolean = true):void{ 56 | if(lzm.Alert.dialogs.indexOf(dialog) != -1){ 57 | return; 58 | } 59 | 60 | dialog.addEventListener(egret.Event.ADDED_TO_STAGE,lzm.Alert.dialogAddToStage,dialog); 61 | 62 | lzm.Alert.container().addChild(lzm.Alert.background); 63 | lzm.Alert.container().addChild(dialog); 64 | 65 | if(setXY){ 66 | dialog.anchorOffsetX = dialog.width / 2; 67 | dialog.anchorOffsetY = dialog.height / 2; 68 | dialog.x = lzm.Alert.stageWidth / 2; 69 | dialog.y = lzm.Alert.stageHeight / 2; 70 | } 71 | dialog.scaleX = dialog.scaleY = 0.1; 72 | egret.Tween.get(dialog).to({scaleX:lzm.Alert.alertScale,scaleY:lzm.Alert.alertScale},300,egret.Ease.backOut); 73 | } 74 | 75 | private static dialogAddToStage(e:egret.Event):void{ 76 | var dialog:egret.DisplayObject = e.currentTarget; 77 | dialog.removeEventListener(egret.Event.ADDED_TO_STAGE,lzm.Alert.dialogAddToStage,dialog); 78 | dialog.addEventListener(egret.Event.REMOVED_FROM_STAGE,lzm.Alert.dialogRemoveFromStage,dialog); 79 | 80 | lzm.Alert.dialogs.push(dialog); 81 | } 82 | 83 | private static dialogRemoveFromStage(e:egret.Event):void{ 84 | var dialog:egret.DisplayObject = e.currentTarget; 85 | dialog.removeEventListener(egret.Event.REMOVED_FROM_STAGE,lzm.Alert.dialogRemoveFromStage,dialog); 86 | 87 | lzm.Alert.dialogs.pop(); 88 | 89 | if(lzm.Alert.dialogs.length == 0){ 90 | if(lzm.Alert.background.parent == lzm.Alert.container()) lzm.Alert.container().removeChild(lzm.Alert.background); 91 | }else{ 92 | while(lzm.Alert.dialogs.length > 0){ 93 | dialog = lzm.Alert.dialogs[lzm.Alert.dialogs.length-1]; 94 | if(dialog.parent == lzm.Alert.container()){ 95 | lzm.Alert.container().swapChildren(lzm.Alert.background,dialog); 96 | break; 97 | }else{ 98 | lzm.Alert.dialogs.pop(); 99 | } 100 | } 101 | if(lzm.Alert.dialogs.length == 0){ 102 | if(lzm.Alert.background.parent == lzm.Alert.container()) lzm.Alert.container().removeChild(lzm.Alert.background); 103 | } 104 | } 105 | } 106 | 107 | public static closeAllAlert(){ 108 | var len:number = Alert.dialogs.length; 109 | var obj:egret.DisplayObject; 110 | var disposeFun:any; 111 | var tmpArr:egret.DisplayObject[] = []; 112 | for(var i:number = 0; i < len ; i++){ 113 | tmpArr.push(Alert.dialogs[i]); 114 | } 115 | for(var i:number = 0; i < len ; i++){ 116 | obj = tmpArr[i]; 117 | disposeFun = obj["dispose"]; 118 | if(disposeFun instanceof Function){ 119 | (disposeFun).apply(obj,[]); 120 | } 121 | if(obj.parent != null) obj.parent.removeChild(obj); 122 | } 123 | } 124 | 125 | 126 | 127 | } 128 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/display/BasePanel.ts: -------------------------------------------------------------------------------- 1 | module lzm { 2 | export class BasePanel extends egret.DisplayObjectContainer { 3 | 4 | public constructor() { 5 | super(); 6 | this.addEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this); 7 | this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.removeFromStage,this); 8 | } 9 | 10 | 11 | public addToStage(e:egret.Event){ 12 | 13 | } 14 | 15 | public removeFromStage(e:egret.Event){ 16 | 17 | } 18 | 19 | public gotoPanel(panel:lzm.BasePanel){ 20 | this.parent.addChild(panel); 21 | this.dispose(); 22 | } 23 | 24 | public dispose(){ 25 | if(this.parent != null){ 26 | this.parent.removeChild(this); 27 | } 28 | this.removeEventListener(egret.Event.ADDED_TO_STAGE,this.addToStage,this); 29 | this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.removeFromStage,this); 30 | } 31 | 32 | 33 | 34 | } 35 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/Swf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | module starlingswf{ 5 | /** 6 | * Swf文档类 7 | * */ 8 | export class Swf{ 9 | 10 | public static dataKey_Sprite:string = "spr"; 11 | public static dataKey_Image:string = "img"; 12 | public static dataKey_MovieClip:string = "mc"; 13 | public static dataKey_TextField:string = "text"; 14 | public static dataKey_Button:string = "btn"; 15 | public static dataKey_Scale9:string = "s9"; 16 | public static dataKey_ShapeImg:string = "shapeImg"; 17 | public static dataKey_Component:string = "comp"; 18 | public static dataKey_Particle:string = "particle"; 19 | 20 | //创建对象的方法 21 | private _createDisplayFuns:Object; 22 | 23 | //swf数据 24 | private _swfData:Object; 25 | //动画更新器 26 | public swfUpdateManager:starlingswf.SwfUpdateManager; 27 | 28 | constructor(swfData:Object,fps:number = 24){ 29 | this._swfData = swfData; 30 | 31 | this._createDisplayFuns = new Object(); 32 | this._createDisplayFuns[Swf.dataKey_Sprite] = this.createSprite; 33 | this._createDisplayFuns[Swf.dataKey_MovieClip] = this.createMovie; 34 | this._createDisplayFuns[Swf.dataKey_Button] = this.createButton; 35 | this._createDisplayFuns[Swf.dataKey_Image] = this.createImage; 36 | this._createDisplayFuns[Swf.dataKey_Scale9] = this.createS9Image; 37 | this._createDisplayFuns[Swf.dataKey_ShapeImg] = this.createShapeImage; 38 | this._createDisplayFuns[Swf.dataKey_TextField] = this.createTextField; 39 | 40 | this.swfUpdateManager = starlingswf.SwfUpdateManager.createSwfUpdateManager(fps); 41 | } 42 | 43 | public createSprite(name:string,data:any[] = null,sprData:any[] = null):starlingswf.SwfSprite{ 44 | if(sprData == null){ 45 | sprData = this._swfData[Swf.dataKey_Sprite][name]; 46 | } 47 | 48 | var sprite:starlingswf.SwfSprite = new starlingswf.SwfSprite(); 49 | var length:number = sprData.length; 50 | var objData:any[]; 51 | var display:egret.DisplayObject; 52 | var fun:Function; 53 | var swf:Swf; 54 | for (var i:number = 0; i < length; i++) { 55 | objData = sprData[i]; 56 | 57 | fun = this._createDisplayFuns[objData[1]]; 58 | if(fun == null) continue; 59 | display = fun.apply(this,[objData[0],objData]); 60 | display.name = objData[9]; 61 | display.x = objData[2]; 62 | display.y = objData[3]; 63 | if(objData[1] == Swf.dataKey_TextField){ 64 | display.y += 6; 65 | } 66 | if(objData[1] != Swf.dataKey_Scale9 && objData[1] != Swf.dataKey_ShapeImg){ 67 | display.scaleX = objData[4]; 68 | display.scaleY = objData[5]; 69 | } 70 | display.skewX = objData[6]; 71 | display.skewY = objData[7]; 72 | display.alpha = objData[8]; 73 | sprite.addChild(display); 74 | } 75 | 76 | if(data != null){ 77 | starlingswf.SwfBlendMode.setBlendMode(sprite,data[11]); 78 | } 79 | 80 | return sprite; 81 | } 82 | 83 | public createMovie(name:string,data:any[]=null):starlingswf.SwfMovieClip{ 84 | var movieClipData:Object = this._swfData[Swf.dataKey_MovieClip][name]; 85 | var objectCountData:Object = movieClipData["objCount"]; 86 | var displayObjects:Object = {}; 87 | var displayObjectArray:any[]; 88 | var type:string; 89 | var count:number; 90 | var fun:Function; 91 | var objName:string; 92 | for(objName in objectCountData){ 93 | type = objectCountData[objName][0]; 94 | count = objectCountData[objName][1]; 95 | 96 | displayObjectArray = displayObjects[objName] == null ? [] : displayObjects[objName]; 97 | 98 | for (var i:number = 0; i < count; i++) { 99 | fun = this._createDisplayFuns[type]; 100 | if(fun == null) continue; 101 | displayObjectArray.push(fun.apply(this,[objName,null])); 102 | } 103 | 104 | displayObjects[objName] = displayObjectArray; 105 | } 106 | 107 | var mc:starlingswf.SwfMovieClip = new starlingswf.SwfMovieClip(movieClipData["frames"],movieClipData["labels"],displayObjects,this,movieClipData["frameEvents"]); 108 | mc.loop = movieClipData["loop"]; 109 | 110 | if(data != null){ 111 | starlingswf.SwfBlendMode.setBlendMode(mc,data[11]); 112 | } 113 | 114 | return mc; 115 | 116 | } 117 | 118 | /** 119 | * 创建按钮 120 | * */ 121 | public createButton(name:string,data:any[]=null):starlingswf.SwfButton{ 122 | var sprData:any[] = this._swfData[Swf.dataKey_Button][name]; 123 | var skin:SwfSprite = this.createSprite(null,null,sprData); 124 | var button:starlingswf.SwfButton = new starlingswf.SwfButton(skin); 125 | return button; 126 | } 127 | 128 | public createImage(name:string,data:any[] = null):egret.Bitmap{ 129 | var imageData:number[] = this._swfData[Swf.dataKey_Image][name]; 130 | 131 | var bitmap:egret.Bitmap = new egret.Bitmap(); 132 | bitmap.texture = RES.getRes(name); 133 | 134 | bitmap.anchorOffsetX = imageData[0]; 135 | bitmap.anchorOffsetY = imageData[1]; 136 | 137 | if(data != null){ 138 | starlingswf.SwfBlendMode.setBlendMode(bitmap,data[11]); 139 | } 140 | 141 | return bitmap; 142 | } 143 | 144 | public createS9Image(name:string,data:any[] = null):egret.Bitmap{ 145 | var scale9Data:any[] = this._swfData[Swf.dataKey_Scale9][name]; 146 | 147 | var bitmap:egret.Bitmap = new egret.Bitmap(); 148 | bitmap.texture = RES.getRes(name); 149 | bitmap.scale9Grid = new egret.Rectangle(scale9Data[0],scale9Data[1],scale9Data[2],scale9Data[3]); 150 | 151 | if(data != null){ 152 | bitmap.width = data[10]; 153 | bitmap.height = data[11]; 154 | starlingswf.SwfBlendMode.setBlendMode(bitmap,data[13]); 155 | } 156 | 157 | return bitmap; 158 | } 159 | 160 | public createShapeImage(name:string,data:any[] = null):egret.Bitmap{ 161 | var bitmap:egret.Bitmap = new egret.Bitmap(); 162 | bitmap.texture = RES.getRes(name); 163 | 164 | bitmap.fillMode = egret.BitmapFillMode.REPEAT; 165 | if(data != null){ 166 | bitmap.width = data[10]; 167 | bitmap.height = data[11]; 168 | starlingswf.SwfBlendMode.setBlendMode(bitmap,data[13]); 169 | } 170 | return bitmap; 171 | } 172 | 173 | public createTextField(name:String,data:any[] = null):egret.TextField{ 174 | var textfield:egret.TextField = new egret.TextField(); 175 | if(data != null){ 176 | textfield.width = data[10]; 177 | textfield.height = data[11]; 178 | textfield.fontFamily = data[12]; 179 | textfield.textColor = data[13]; 180 | textfield.size = data[14]; 181 | textfield.textAlign = data[15]; 182 | //textfield.italic = data[16]; 183 | //textfield.bold = data[17]; 184 | textfield.text = data[18]; 185 | this.createTextFieldFilter(textfield,data[19]); 186 | starlingswf.SwfBlendMode.setBlendMode(textfield,data[20]); 187 | } 188 | return textfield; 189 | } 190 | 191 | /** 创建文本的滤镜 */ 192 | public createTextFieldFilter(textField:egret.TextField,filterObjects:Object):void{ 193 | for(var filterName in filterObjects){ 194 | if(filterName == "flash.filters::GlowFilter"){ 195 | textField.stroke = filterObjects[filterName]["strength"]; 196 | textField.strokeColor = filterObjects[filterName]["color"]; 197 | } 198 | } 199 | } 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/SwfAnalyzer.ts: -------------------------------------------------------------------------------- 1 | module starlingswf { 2 | export class SwfAnalyzer extends RES.BinAnalyzer { 3 | 4 | public constructor() { 5 | super(); 6 | this._dataFormat = egret.HttpResponseType.TEXT; 7 | } 8 | 9 | /** 10 | * 解析并缓存加载成功的数据 11 | */ 12 | public analyzeData(resItem:RES.ResourceItem, data:any):void { 13 | let name:string = resItem.name; 14 | if (this.fileDic[name] || !data) { 15 | return; 16 | } 17 | try { 18 | let str:string = data; 19 | this.fileDic[name] = new Swf(JSON.parse(str),30); 20 | } 21 | catch (e) { 22 | egret.$warn(1017, resItem.url, data); 23 | } 24 | } 25 | 26 | } 27 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/SwfUpdateManager.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | module starlingswf{ 5 | /** 动画更新管理器 */ 6 | export class SwfUpdateManager{ 7 | private _animations:starlingswf.ISwfAnimation[]; 8 | 9 | private _addQueue:starlingswf.ISwfAnimation[];//添加队列 10 | private _removeQueue:starlingswf.ISwfAnimation[];//移除队列 11 | 12 | private _fps:number; 13 | private _fpsTime:number; 14 | private _currentTime:number; 15 | 16 | public static createSwfUpdateManager(fps:number):SwfUpdateManager{ 17 | var updateManager:SwfUpdateManager = new SwfUpdateManager(); 18 | updateManager._animations = []; 19 | updateManager._addQueue = []; 20 | updateManager._removeQueue = []; 21 | updateManager._currentTime = 0; 22 | updateManager.setFps(fps); 23 | 24 | egret.Ticker.getInstance().register(updateManager.update,updateManager); 25 | 26 | return updateManager; 27 | } 28 | 29 | public setFps(fps:number):void{ 30 | this._fps = fps; 31 | this._fpsTime = 1000 / fps; 32 | } 33 | 34 | public addSwfAnimation(animation:starlingswf.ISwfAnimation):void{ 35 | this._addQueue.push(animation); 36 | } 37 | 38 | public removeSwfAnimation(animation:starlingswf.ISwfAnimation):void{ 39 | this._removeQueue.push(animation); 40 | } 41 | 42 | private updateAdd():void{ 43 | var len:number = this._addQueue.length; 44 | var index:number; 45 | var animation:ISwfAnimation; 46 | for(var i:number = 0; i < len; i++){ 47 | animation = this._addQueue.pop(); 48 | index = this._animations.indexOf(animation); 49 | if(index == -1){ 50 | this._animations.push(animation); 51 | } 52 | } 53 | } 54 | 55 | private updateRemove():void{ 56 | var len:number = this._removeQueue.length; 57 | var index:number; 58 | var animation:ISwfAnimation; 59 | for(var i:number = 0; i < len; i++){ 60 | animation = this._removeQueue.pop(); 61 | index = this._animations.indexOf(animation); 62 | if(index != -1){ 63 | this._animations.splice(index,1); 64 | } 65 | } 66 | } 67 | 68 | private update(time:number):void{ 69 | this._currentTime += time; 70 | if(this._currentTime < this._fpsTime){ 71 | return; 72 | } 73 | this._currentTime -= this._fpsTime; 74 | if(this._currentTime > this._fpsTime){ 75 | this._currentTime = 0; 76 | } 77 | this.updateRemove(); 78 | this.updateAdd(); 79 | 80 | var len:number = this._animations.length; 81 | var ani:starlingswf.ISwfAnimation; 82 | for(var i:number = 0; i < len; i++){ 83 | ani = this._animations[i]; 84 | if(ani.getStage() != null) ani.update(); 85 | } 86 | } 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/blendmode/SwfBlendMode.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-9-25. 3 | */ 4 | module starlingswf{ 5 | 6 | export class SwfBlendMode{ 7 | public static modes:Object = { 8 | "normal":true, 9 | "add":true 10 | }; 11 | 12 | public static setBlendMode(display:egret.DisplayObject,blendMode:string):void{ 13 | if(SwfBlendMode.modes[blendMode]){ 14 | display.blendMode = blendMode; 15 | } 16 | } 17 | 18 | } 19 | 20 | 21 | 22 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/display/ISwfAnimation.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | module starlingswf{ 5 | /** 6 | * 动画接口 7 | * */ 8 | export interface ISwfAnimation{ 9 | update():void; 10 | getStage():egret.Stage; 11 | } 12 | 13 | 14 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/display/SwfButton.ts: -------------------------------------------------------------------------------- 1 | module starlingswf { 2 | export class SwfButton extends starlingswf.SwfSprite { 3 | 4 | static onClick:string = "SwfButton.onClick"; 5 | static defSound:egret.Sound; 6 | 7 | public skin:egret.DisplayObject; 8 | public defScale:number = -1; 9 | 10 | private _w:number; 11 | private _h:number; 12 | 13 | public constructor(skin:egret.DisplayObject) { 14 | super(); 15 | this.skin = skin; 16 | this._w = this.skin.width; 17 | this._h = this.skin.height; 18 | this.addChild(skin); 19 | this.touchEnabled = true; 20 | this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.mouseDown,this); 21 | this.addEventListener(egret.TouchEvent.TOUCH_END,this.mouseUp,this); 22 | this.addEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.mouseUp,this); 23 | this.addEventListener(egret.TouchEvent.TOUCH_TAP,this.mouseClick,this); 24 | } 25 | 26 | public mouseDown(evt:egret.TouchEvent):void{ 27 | this.skin.scaleX = 1.1; 28 | this.skin.scaleY = 1.1; 29 | this.skin.x = (1.0 - 1.1) / 2.0 * this._w; 30 | this.skin.y = (1.0 - 1.1) / 2.0 * this._h; 31 | } 32 | 33 | public mouseUp(evt:egret.TouchEvent):void{ 34 | this.skin.scaleX = 1; 35 | this.skin.scaleY = 1; 36 | this.skin.x = this.skin.y = 0; 37 | } 38 | 39 | public mouseClick(evt:egret.TouchEvent):void{ 40 | this.dispatchEventWith(starlingswf.SwfButton.onClick); 41 | if(SwfButton.defSound != null) SwfButton.defSound.play(0,1); 42 | } 43 | 44 | public setEnable(val:boolean){ 45 | this.touchEnabled = val; 46 | if(val){ 47 | this.filters = null; 48 | }else{ 49 | var colorMatrix = [ 50 | 0.3,0.6,0,0,0, 51 | 0.3,0.6,0,0,0, 52 | 0.3,0.6,0,0,0, 53 | 0,0,0,1,0 54 | ]; 55 | var colorFlilter = new egret.ColorMatrixFilter(colorMatrix); 56 | this.filters = [colorFlilter]; 57 | } 58 | } 59 | 60 | public dispose(){ 61 | this.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.mouseDown,this); 62 | this.removeEventListener(egret.TouchEvent.TOUCH_END,this.mouseUp,this); 63 | this.removeEventListener(egret.TouchEvent.TOUCH_RELEASE_OUTSIDE,this.mouseUp,this); 64 | this.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.mouseClick,this); 65 | } 66 | } 67 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/display/SwfMovieClip.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | module starlingswf{ 5 | export class SwfMovieClip extends starlingswf.SwfSprite implements starlingswf.ISwfAnimation{ 6 | 7 | private _ownerSwf:starlingswf.Swf;//所属swf 8 | 9 | private _frames:any[]; 10 | private _labels:any[]; 11 | private _frameEvents:Object; 12 | private _displayObjects:Object; 13 | 14 | private _startFrame:number; 15 | private _endFrame:number; 16 | private _currentFrame:number; 17 | private _currentLabel:string; 18 | 19 | private _isPlay:boolean = false; 20 | public loop:boolean = true; 21 | 22 | private _completeFunction:Function = null;//播放完毕的回调 23 | private _hasCompleteListener:Boolean = false;//是否监听过播放完毕的事件 24 | 25 | constructor(frames:any[],labels:any[],displayObjects:Object,ownerSwf:starlingswf.Swf,frameEvents:Object = null){ 26 | super(); 27 | 28 | this._frames = frames; 29 | this._labels = labels; 30 | this._displayObjects = displayObjects; 31 | this._frameEvents = frameEvents; 32 | 33 | this._startFrame = 0; 34 | this._endFrame = this._frames.length - 1; 35 | this._ownerSwf = ownerSwf; 36 | 37 | this.setCurrentFrame(0); 38 | this.play(); 39 | 40 | } 41 | 42 | public getStage():egret.Stage{ 43 | if(this.visible){ 44 | return this.stage; 45 | } 46 | return null; 47 | } 48 | 49 | public update():void { 50 | if (!this._isPlay) return; 51 | 52 | if(this._currentFrame >= this._endFrame){ 53 | var isReturn:boolean = false; 54 | 55 | if(!this.loop || this._startFrame == this._endFrame){//只有一帧就不要循环下去了 56 | if(this._ownerSwf) this.stop(false); 57 | isReturn = true; 58 | } 59 | 60 | if(this._completeFunction) this._completeFunction(this); 61 | if(this._hasCompleteListener) this.dispatchEventWith(egret.Event.COMPLETE); 62 | 63 | if(isReturn) return; 64 | 65 | this._currentFrame = this._startFrame; 66 | }else{ 67 | this._currentFrame ++ 68 | } 69 | this.setCurrentFrame(this._currentFrame); 70 | } 71 | 72 | private __frameInfos:any[]; 73 | public setCurrentFrame(frame:number):void{ 74 | //dirty hack this.removeChildren(); 75 | // this.$children.length = 0; 76 | this.removeAllChilds(); 77 | 78 | this._currentFrame = frame; 79 | this.__frameInfos = this._frames[this._currentFrame]; 80 | 81 | var data:any[]; 82 | var display:egret.DisplayObject; 83 | var textfield:egret.TextField; 84 | var useIndex:number; 85 | var length:number = this.__frameInfos.length; 86 | for (var i:number = 0; i < length; i++) { 87 | data = this.__frameInfos[i]; 88 | useIndex = data[10]; 89 | display = this._displayObjects[data[0]][useIndex]; 90 | 91 | display.$setSkewX(data[6]); 92 | display.$setSkewY(data[7]);; 93 | display.$setAlpha(data[8]); 94 | display.name = data[9]; 95 | 96 | // if(data[1] == Swf.dataKey_Particle){ 97 | // display["setPostion"](data[2],data[3]); 98 | // }else{ 99 | display.$setX(data[2]); 100 | display.$setY(data[3]); 101 | // } 102 | 103 | switch(data[1]){ 104 | case starlingswf.Swf.dataKey_Scale9: 105 | display.width = data[11]; 106 | display.height = data[12]; 107 | starlingswf.SwfBlendMode.setBlendMode(display,data[13]); 108 | break; 109 | case starlingswf.Swf.dataKey_ShapeImg: 110 | display.width = data[11]; 111 | display.height = data[12]; 112 | starlingswf.SwfBlendMode.setBlendMode(display,data[13]); 113 | break; 114 | case starlingswf.Swf.dataKey_TextField: 115 | textfield = display; 116 | textfield.width = data[11]; 117 | textfield.height = data[12]; 118 | textfield.fontFamily = data[13]; 119 | textfield.textColor = data[14]; 120 | textfield.size = data[15]; 121 | textfield.textAlign = data[16]; 122 | // textfield["italic"] = data[17]; 123 | // textfield["bold"] = data[18]; 124 | if(data[19] && data[19] != "\r" && data[19] != ""){ 125 | textfield.text = data[19]; 126 | } 127 | starlingswf.SwfBlendMode.setBlendMode(textfield,data[20]); 128 | break; 129 | default: 130 | display.$setScaleX(data[4]); 131 | display.$setScaleY(data[5]); 132 | starlingswf.SwfBlendMode.setBlendMode(display,data[11]); 133 | break; 134 | } 135 | 136 | this.$doAddChild(display,length,false); 137 | 138 | // this.$children.push(display); 139 | // display.$parent = this; 140 | } 141 | 142 | if(this._frameEvents != null && this._frameEvents[this._currentFrame] != null){ 143 | this.dispatchEventWith(this._frameEvents[this._currentFrame]); 144 | } 145 | 146 | } 147 | 148 | public getCurrentFrame():number{ 149 | return this._currentFrame; 150 | } 151 | 152 | /** 153 | * 播放 154 | * */ 155 | public play():void{ 156 | this._isPlay = true; 157 | 158 | this._ownerSwf.swfUpdateManager.addSwfAnimation(this); 159 | 160 | var k:string; 161 | var arr:any[]; 162 | var l:number; 163 | for(k in this._displayObjects){ 164 | if(k.indexOf(starlingswf.Swf.dataKey_MovieClip) == 0){ 165 | arr = this._displayObjects[k]; 166 | l = arr.length; 167 | for (var i:number = 0; i < l; i++) { 168 | (arr[i]).play(); 169 | } 170 | } 171 | } 172 | } 173 | 174 | /** 175 | * 停止 176 | * @param stopChild 是否停止子动画 177 | * */ 178 | public stop(stopChild:boolean = true):void{ 179 | this._isPlay = false; 180 | this._ownerSwf.swfUpdateManager.removeSwfAnimation(this); 181 | 182 | if(!stopChild) return; 183 | 184 | var k:string; 185 | var arr:any[]; 186 | var l:number; 187 | for(k in this._displayObjects){ 188 | if(k.indexOf(starlingswf.Swf.dataKey_MovieClip) == 0){ 189 | arr = this._displayObjects[k]; 190 | l = arr.length; 191 | for (var i:number = 0; i < l; i++) { 192 | (arr[i]).stop(stopChild); 193 | } 194 | } 195 | } 196 | } 197 | 198 | public gotoAndStop(frame:Object,stopChild:boolean = true):void{ 199 | this.goTo(frame); 200 | this.stop(stopChild); 201 | } 202 | 203 | public gotoAndPlay(frame:Object):void{ 204 | this.goTo(frame); 205 | this.play(); 206 | } 207 | 208 | private goTo(frame:any):void{ 209 | if(typeof(frame) == "string"){ 210 | var labelData:any[] = this.getLabelData(frame); 211 | this._currentLabel = labelData[0]; 212 | this._currentFrame = this._startFrame = labelData[1]; 213 | this._endFrame = labelData[2]; 214 | }else if(typeof(frame) == "number"){ 215 | this._currentFrame = this._startFrame = frame; 216 | this._endFrame = this._frames.length - 1; 217 | } 218 | this.setCurrentFrame(this._currentFrame); 219 | } 220 | 221 | private getLabelData(label:String):any[]{ 222 | var length:number = this._labels.length; 223 | var labelData:any[]; 224 | for (var i:number = 0; i < length; i++) { 225 | labelData = this._labels[i]; 226 | if(labelData[0] == label){ 227 | return labelData; 228 | } 229 | } 230 | return null; 231 | } 232 | 233 | /** 234 | * 是否再播放 235 | * */ 236 | public isPlay():boolean{ 237 | return this._isPlay; 238 | } 239 | 240 | /** 241 | * 总共有多少帧 242 | * */ 243 | public totalFrames():number{ 244 | return this._frames.length; 245 | } 246 | 247 | /** 248 | * 返回当前播放的是哪一个标签 249 | * */ 250 | public currentLabel():string{ 251 | return this._currentLabel; 252 | } 253 | 254 | /** 255 | * 获取所有标签 256 | * */ 257 | public labels():any[]{ 258 | var length:number = this._labels.length; 259 | var returnLabels:any[] = []; 260 | for (var i:number = 0; i < length; i++) { 261 | returnLabels.push(this._labels[i][0]); 262 | } 263 | return returnLabels; 264 | } 265 | 266 | /** 267 | * 是否包含某个标签 268 | * */ 269 | public hasLabel(label:String):Boolean{ 270 | var ls:any[] = this.labels(); 271 | return !(ls.indexOf(label) == -1); 272 | } 273 | 274 | public addEventListener1(type:string, listener:Function, thisObject:any, useCapture:boolean = false, priority:number = 0):void{ 275 | this.addEventListener(type,listener,thisObject,useCapture,priority); 276 | this._hasCompleteListener = this.hasEventListener(egret.Event.COMPLETE); 277 | } 278 | 279 | public removeEventListener1(type:string, listener:Function,thisObject:any,useCapture:boolean = false):void{ 280 | this.removeEventListener(type,listener,thisObject,useCapture); 281 | this._hasCompleteListener = this.hasEventListener(egret.Event.COMPLETE); 282 | } 283 | 284 | 285 | private removeAllChilds():void{ 286 | let children = this.$children; 287 | for (let i: number = children.length - 1; i >= 0; i--) { 288 | this.$doRemoveChild(i,false); 289 | } 290 | } 291 | } 292 | } 293 | -------------------------------------------------------------------------------- /libsrc/src/lzm/starlingswf/display/SwfSprite.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by zmliu on 14-5-11. 3 | */ 4 | module starlingswf{ 5 | /**Sprite*/ 6 | export class SwfSprite extends egret.DisplayObjectContainer{ 7 | 8 | public getTextField(name:string):egret.TextField{ 9 | return this.getChildByName(name); 10 | } 11 | 12 | public getMovie(name:string):starlingswf.SwfMovieClip{ 13 | return this.getChildByName(name); 14 | } 15 | 16 | public getSprite(name:string):starlingswf.SwfSprite{ 17 | return this.getChildByName(name); 18 | } 19 | 20 | public getImage(name:string):egret.Bitmap{ 21 | return this.getChildByName(name); 22 | } 23 | 24 | public getButton(name:string):starlingswf.SwfButton{ 25 | return this.getChildByName(name); 26 | } 27 | 28 | } 29 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/utils/HttpClient.ts: -------------------------------------------------------------------------------- 1 | module lzm { 2 | export class HttpClient { 3 | 4 | /** 5 | * 请求url 6 | */ 7 | public static send(url:string,params:Object,completeFunction:Function=null,timeoutFunction:Function=null,method:String="get"):void{ 8 | var request:egret.HttpRequest = new egret.HttpRequest(); 9 | var parStr = lzm.HttpClient.getRequestPars(params); 10 | 11 | var callback:Function = function(e:egret.Event):void{ 12 | request.removeEventListener(egret.Event.COMPLETE,callback,request); 13 | request.removeEventListener(egret.IOErrorEvent.IO_ERROR,timeout,request); 14 | if(completeFunction!=null){ 15 | completeFunction(request.response); 16 | } 17 | }; 18 | 19 | var timeout:Function = function(e:egret.IOErrorEvent):void{ 20 | request.removeEventListener(egret.Event.COMPLETE,callback,request); 21 | request.removeEventListener(egret.IOErrorEvent.IO_ERROR,timeout,request); 22 | if(timeoutFunction != null){ 23 | timeoutFunction(request.response); 24 | } 25 | }; 26 | 27 | request.addEventListener(egret.Event.COMPLETE,callback,request); 28 | request.addEventListener(egret.IOErrorEvent.IO_ERROR,timeout,request); 29 | request.responseType = egret.HttpResponseType.TEXT; 30 | if(method=="get"){ 31 | if(parStr != ""){ 32 | request.open(url + "?" + parStr,egret.HttpMethod.GET); 33 | }else{ 34 | request.open(url,egret.HttpMethod.GET); 35 | } 36 | request.send(); 37 | }else if(method=="post"){ 38 | request.open(url,egret.HttpMethod.POST); 39 | request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); 40 | request.send(parStr); 41 | } 42 | } 43 | 44 | static getRequestPars(params:Object):string{ 45 | var pars:string = ""; 46 | var k:string; 47 | for (k in params){ 48 | pars += k+"="+params[k] + "&"; 49 | } 50 | return pars.substr(0,pars.length-1); 51 | } 52 | 53 | } 54 | } -------------------------------------------------------------------------------- /libsrc/src/lzm/utils/JSONWebSocketClient.ts: -------------------------------------------------------------------------------- 1 | module lzm { 2 | export class JSONWebSocketClient { 3 | 4 | private socket:egret.WebSocket; 5 | private host:string; 6 | private port:number; 7 | 8 | public isConnect:boolean = false; 9 | public onConnectCallBack:Function; 10 | public onIOErrorCallBack:Function; 11 | public onCloseCallBack:Function; 12 | public onDataCallBack:Function; 13 | 14 | public constructor(host:string,port:number) { 15 | this.host = host; 16 | this.port = port; 17 | this.socket = new egret.WebSocket(); 18 | this.socket.addEventListener(egret.ProgressEvent.SOCKET_DATA, this.onReceiveMessage, this); 19 | this.socket.addEventListener(egret.Event.CONNECT, this.onSocketOpen, this); 20 | this.socket.addEventListener(egret.Event.CLOSE, this.onSocketClose, this); 21 | this.socket.addEventListener(egret.IOErrorEvent.IO_ERROR, this.onSocketIOError, this); 22 | } 23 | 24 | public connect():void{ 25 | this.socket.connect(this.host,this.port); 26 | } 27 | 28 | public sendData(data:Object):void{ 29 | this.socket.writeUTF(JSON.stringify(data)); 30 | } 31 | 32 | private onSocketOpen():void { 33 | this.isConnect = true; 34 | if(this.onConnectCallBack != null) this.onConnectCallBack(); 35 | } 36 | private onReceiveMessage(e:egret.Event):void { 37 | var msg = this.socket.readUTF(); 38 | if(this.onDataCallBack != null) this.onDataCallBack(JSON.parse(msg)); 39 | } 40 | private onSocketClose(e:egret.Event):void { 41 | this.isConnect = false; 42 | if(this.onCloseCallBack != null) this.onCloseCallBack(); 43 | } 44 | private onSocketIOError(e:egret.IOErrorEvent):void { 45 | if(this.onIOErrorCallBack != null) this.onIOErrorCallBack(); 46 | } 47 | 48 | public dispose(){ 49 | this.socket.close(); 50 | this.onConnectCallBack = null; 51 | this.onIOErrorCallBack = null; 52 | this.onCloseCallBack = null; 53 | this.onDataCallBack = null; 54 | } 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /libsrc/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "noImplicitAny": false, 5 | "sourceMap": false, 6 | "declaration": true, 7 | "outFile": "bin/starlingSwf/starlingSwf.js" 8 | }, 9 | "include": [ 10 | "src", 11 | "libs" 12 | ] 13 | } --------------------------------------------------------------------------------