class Main
    {
        public constructor() {
            //添加资源配置加载完成事件
            RES.addEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
            //加载配置
            RES.loadConfig(“resource/default.res.json”, “resource/”);
        }
        /**
         * 配置文件加载完成,开始预加载preload资源组。
         */
        private onConfigComplete(event:RES.ResourceEvent):void
        {
            RES.removeEventListener(RES.ResourceEvent.CONFIG_COMPLETE, this.onConfigComplete, this);
            //添加资源组加载完成事件
            RES.addEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this);
            //添加资源组加载失败事件
            RES.addEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this);
            //添加资源加载失败事件
            RES.addEventListener(RES.ResourceEvent.ITEM_LOAD_ERROR, this.onResourceItemLoadError, this);
            //添加资源组加载进度事件
            RES.addEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this);
            //开始加载 preload 资源组
            RES.loadGroup(“preload”);
        }
        /**
         * preload资源组加载完成
         */
        private onResourceLoadComplete(event:RES.ResourceEvent):void {
            if (event.groupName == “preload”) {
                RES.removeEventListener(RES.ResourceEvent.GROUP_COMPLETE, this.onResourceLoadComplete, this);
                RES.removeEventListener(RES.ResourceEvent.GROUP_LOAD_ERROR, this.onResourceLoadError, this);
                RES.removeEventListener(RES.ResourceEvent.GROUP_PROGRESS, this.onResourceProgress, this);
                this.trace(“preload组加载完成”);
                paper.Application.sceneManager.createScene(“defaultScene”);
                var _game:GameScene = new GameScene();
            }
        }
        /**
         * preload资源组加载进度
         * Loading process of preload resource group
         */
        private onResourceProgress(event:RES.ResourceEvent):void {
            if (event.groupName == “preload”) {
                this.trace(“preload资源加载进度 : ” + event.itemsLoaded + ” / ” + event.itemsTotal);
            }
        }
        /**
         * 资源组加载出错
         */
        private onResourceLoadError(event:RES.ResourceEvent):void {
            this.trace(“preload组加载失败”);
            //忽略加载失败的项目
            this.onResourceLoadComplete(event);
        }
        /**
         * 资源加载出错
         */
        private onResourceItemLoadError(event:RES.ResourceEvent):void {
            this.trace(“项目加载失败,url : ” + event.resItem.url);
        }
        private trace(msg:any):void {
            egret.log(msg);
        }
    }