зеркало из https://github.com/mozilla/shumway.git
Fix image loading events
This commit is contained in:
Родитель
785d2cd958
Коммит
37956ffc45
|
@ -138,9 +138,11 @@ module Shumway.AVM2.AS.flash.display {
|
|||
false, false, bytesLoaded,
|
||||
bytesTotal));
|
||||
loaderInfo.dispatchEvent(events.Event.getInstance(events.Event.COMPLETE));
|
||||
queue.splice(i--, 1);
|
||||
}
|
||||
break;
|
||||
case LoadStatus.Complete:
|
||||
queue.splice(i--, 1);
|
||||
break;
|
||||
default:
|
||||
assertUnreachable("Mustn't encounter unhandled status in Loader queue.");
|
||||
}
|
||||
|
@ -278,6 +280,9 @@ module Shumway.AVM2.AS.flash.display {
|
|||
} else {
|
||||
release || assert (loaderInfo._bytesTotal === bytesTotal, "Total bytes should not change.");
|
||||
}
|
||||
if (info.open && this._loadStatus === LoadStatus.Unloaded) {
|
||||
this._loadStatus = LoadStatus.Opened;
|
||||
}
|
||||
if (this._loadStatus !== LoadStatus.Unloaded) {
|
||||
loaderInfo.dispatchEvent(new events.ProgressEvent(events.ProgressEvent.PROGRESS, false,
|
||||
false, bytesLoaded, bytesTotal));
|
||||
|
@ -570,7 +575,10 @@ module Shumway.AVM2.AS.flash.display {
|
|||
loaderInfo._width = symbol.width;
|
||||
loaderInfo._height = symbol.height;
|
||||
|
||||
this._loadStatus = LoadStatus.Opened;
|
||||
// Complete load process manually here to avoid any additional progress events to be fired.
|
||||
loaderInfo.dispatchEvent(events.Event.getInstance(events.Event.INIT));
|
||||
loaderInfo.dispatchEvent(events.Event.getInstance(events.Event.COMPLETE));
|
||||
this._loadStatus = LoadStatus.Complete;
|
||||
}
|
||||
|
||||
get content(): flash.display.DisplayObject {
|
||||
|
|
|
@ -438,6 +438,8 @@ module Shumway.SWF.Parser {
|
|||
options.oncomplete && options.oncomplete(symbol);
|
||||
}
|
||||
};
|
||||
|
||||
options.onimgprogress(bytesTotal);
|
||||
}
|
||||
|
||||
return pipe;
|
||||
|
|
|
@ -186,6 +186,17 @@ module Shumway.SWF {
|
|||
onstart: function (result) {
|
||||
commitData({command: 'init', result: result});
|
||||
},
|
||||
onimgprogress: function (bytesTotal) {
|
||||
// image progress events are sent with 1K increments
|
||||
while (bytesLoaded <= bytesTotal) {
|
||||
commitData({command: 'progress', result: {
|
||||
bytesLoaded: bytesLoaded,
|
||||
bytesTotal: bytesTotal,
|
||||
open: true
|
||||
}});
|
||||
bytesLoaded += Math.min(bytesTotal - bytesLoaded || 1024, 1024);
|
||||
}
|
||||
},
|
||||
onprogress: function (result) {
|
||||
// sending progress events with 64K increments
|
||||
if (result.bytesLoaded - bytesLoaded >= 65536) {
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 8.4 KiB |
Двоичный файл не отображается.
Двоичный файл не отображается.
|
@ -0,0 +1,12 @@
|
|||
progress, bytesLoaded: 0, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 1024, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 2048, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 3072, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 4096, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 5120, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 6144, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 7168, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 8192, bytesLoaded: 8647
|
||||
progress, bytesLoaded: 8647, bytesLoaded: 8647
|
||||
init
|
||||
complete
|
|
@ -424,5 +424,12 @@
|
|||
"swfs/hitTestStyleChange.swf"
|
||||
],
|
||||
"type": "stas"
|
||||
},
|
||||
{ "id": "image-loading",
|
||||
"stas": "swfs/trace.stas",
|
||||
"filenames": [
|
||||
"swfs/image-loading/image-loading.swf"
|
||||
],
|
||||
"type": "stas"
|
||||
}
|
||||
]
|
||||
|
|
Загрузка…
Ссылка в новой задаче