我將多個圖像加載到一個類實例中,我想跟蹤在任何給定點上加載數據的完整數量有多大。 我通過PHP腳本從圖像目錄中抓取了總字節數...但是從每個圖像上的ProgressEvent收集新字節似乎很棘手,因爲某些原因。 我們假設totalBytes變量是正確的,並且我完全不熟悉ProgressEvent的工作方式...AS3:從多個來源加載字節
每次ProgressEvent獲取新字節時,都會觸發一個事件嗎?
如果不是,我如何跟蹤當前的總字節數?
我敢肯定,我弄錯了,但這裏是我想:
public function thumbProgress(e:ProgressEvent):void
{
//trying to check for a new data amount, in case the progress event updates
//insignificantly
if(e.bytesLoaded != this.newByte)
{
this.newByte = this.currentLoadedBytes - e.bytesLoaded;
this.currentLoadedBytes += this.newByte;
this.textprog.text = this.currentLoadedBytes.toString() + "/" + this.totalBytes.toString();
this.newByte = e.bytesLoaded;
}
if(this.currentLoadedBytes >= this.totalBytes)
{
this.textprog.text = "done loading.";
}
}
這似乎是我所期待的。 有趣的是,我從來沒有嘗試添加總onComplete之前。 謝謝。 – jml 2010-01-02 16:54:20
呃,其實我不認爲這會奏效。 我需要INIT處理程序來完成w/r/totalBytes屬性的工作。這個數字在這個時候也應該是可用的嗎? 我不會認爲圖像必須先加載才能訪問它。 – jml 2010-01-02 17:14:21