BulkLoader还是很方便的,就是有个总字节不对的问题(可能是问题,因为文档我没仔细看,如果是我使用的问题,请哪位大神指出),我在这里说一个解决的办法,在代码里添了一句。
BulkLoader里
view sourceprint?
01 public function _onProgress(evt : Event = null) : void{
02 // TODO: check these values are correct! tough _onProgress
03 var e : BulkProgressEvent = getProgressForItems(_items);
04 // update values:
05 _bytesLoaded = e.bytesLoaded;
06 _bytesTotal = e.bytesTotal;
07 _weightPercent = e.weightPercent;
08 _percentLoaded = e.percentLoaded;
09 _bytesTotalCurrent = e.bytesTotalCurrent;
10 _loadedRatio = e.ratioLoaded;
11 <SPAN style="BACKGROUND-COLOR: #ffff00">dispatchEvent(new MyProgressEvent(evt.target.bytesTotal,evt.target.bytesLoaded));
12 </SPAN> dispatchEvent(e);
13 }
view sourceprint?
1
MyProgressEvent类代码
view sourceprint?
01 package br.com.stimuli.loading {
02 import flash.events.*;
03
04 public class MyProgressEvent extends Event {
05 /* The name of this event */
06 public static const PROGRESS : String = "myprogress";
07
08 /** How many bytes have loaded so far.*/
09 public var bytesTotal : int;
10 public var bytesLoaded:int;
11
12
13 public function MyProgressEvent( bytesTotal:int,bytesLoaded:int, bubbles:Boolean=true, cancelable:Boolean=false ){
14 super(PROGRESS, bubbles, cancelable);
15 this.bytesTotal=bytesTotal;
16 this.bytesLoaded=bytesLoaded;
17 }
18
19 }
20
21 }
SimpleExampleMain里改的部分和需要注意的部分
view sourceprint?
1 loader = new BulkLoader("main-site",1);//注意第2个参数是1,按队列加载,设置其他数字就是并行加载了,你懂的。
loader.addEventListener(MyProgressEvent.PROGRESS,ontest);//加一句监听;
public function ontest(evt : MyProgressEvent) : void{
trace(evt.bytesLoaded,evt.bytesTotal,"------------------")
}
OK 了,这样给出单个文件的加载进程了。
附件是打包好了,嫌麻烦的可以直接测附件