[Question] How to get the number of items in manifest before they are loaded?
Closed this issue · 1 comments
This is an edge use-case but is there currently a way to get the number of items in an external manifest before they are loaded?
I tried to load assets via an external manifest and get their number in a fileload
event callback for the purposes of displaying progress in the form remaining/allFiles
. The problem is that the event triggers last for the manifest itself (I assume this has something to do with the fact that it is only considered loaded once its contents have been loaded):
//Example of an attempt
var fileTypes = createjs.LoadQueue;
preload.on("fileload", function (e) {
var type = e.item.type;
if (type == fileTypes.MANIFEST) {
//Last to load
count = e.loader._manifestQueue._numItems;
}
if (type == fileTypes.CSS || type == fileTypes.JAVASCRIPT) {
document.body.appendChild(e.result);
}
});
preload.loadManifest({ src: manifestSrc, type: "manifest" });
I wasn't able to succesfully solve this via the progress
event either.
Is there currently a way to retreive the number of files in manifests before they are added to a queue/loaded? Thanks in advance for advice
Sorry for the delayed response. The progress
on the LoadQueue falls back to the number of items when there is no progress available on specific items (usually when tag-loading).
You can refer to the internal parameters
- _currentLoads: An array containing the currently downloading files.
- _loadQueue: An array containing the queued items that have not yet started downloading.
- _loadQueueBackup: An array containing downloads that have not completed, so that the LoadQueue can be properly reset.
Open to an alternate approach. Is there value in getting a numFiles / numFilesComplete
or something (my poor naming aside)?
Closing for now. Feel free to reopen if there is a specific issue, or you have a proposal on an enhancement.