View Code
public function main() { //addEventListener(Event.ENTER_FRAME,loadProgress) loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler); loaderInfo.addEventListener(Event.COMPLETE,progressComplete); } //读取进度 function progressHandler(e:ProgressEvent):void { progressText.text="Loading:"+e.target.bytesLoaded+"K/"+e.target.bytesTotal+"K"; if (e.target.bytesLoaded>=e.target.bytesTotal) { this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler); //gotoAndStop(3); //gotoAndStop(2); //init(); //init(); } } function progressComplete(event:Event):void { //this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler); this.loaderInfo.removeEventListener(Event.COMPLETE,progressComplete); //gotoAndStop(3); gotoAndStop(2); init(); //init(); }
监听事件,一个下载中,一个完成时。否则会出现第2次游戏时卡住的问题,progressText为fla上的自建的文本框