好久沒有寫LOADING這東東了
尤其在換了AS3之後
趁著在做APA的機會複習一下
順便把CODE筆記一下吧
stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP; var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;//以paramObj["問號後的參數"] 使用 var urltext:String = "http://domain/"; var xmlname:Array= new Array("","listheadertext.xml","listKnow.xml"); var xmlloader:URLLoader = new URLLoader; var textxml1:XML; var textxml2:XML; var nowload:int = 0; this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,loadfun); this.loaderInfo.addEventListener(Event.COMPLETE,nextfun); xmlloader.addEventListener(ProgressEvent.PROGRESS,loadfun); xmlloader.addEventListener(Event.COMPLETE,nextfun); function loadfun(e:ProgressEvent) { var hl:Number=e.bytesLoaded/e.bytesTotal; if (loading_mc.bar_mc) { loading_mc.bar_mc.scaleX = hl; loading_mc.loadtxt.text = Math.round(hl*100)+"%"; } } function myover(event:Event):void { this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS,loadfun); xmlloader.removeEventListener(ProgressEvent.PROGRESS,loadfun); nextFrame(); } function nextfun(event:Event):void { this["textxml"+nowload] = new XML(xmlloader.data); nowload++; if (nowload<xmlname.length) { xmlloader.load(new URLRequest(urltext+xmlname[nowload])); } else { myover(event); } } |
雖然還不算完整可以套在任何例子
不過還刊用就是….