Copy link to clipboard
Copied
Hey guys,
I face some issues when i'm trying to use loadMaifest for multiple files loading in adobe animate cc html5 mode.
Here is the case. Thanks to kglad got the solution to load a singe file, but in some cases there have to more than one file to be loaded. Here comes loadManifest of LoadQueue class, right. But something in my approach is goes wrong because it multiplies added objects into the container (the place of adding). For example - if i would like to add 2 files then i pass 2 items to the loadManifest it adds 4 objects. If files would be 3 then 9 objects will be added. This is wrong.
Here is the code:
var preload = new createjs.LoadQueue(false);
function loadImage(filename1,filename2) {
preload.addEventListener("fileload", handleFileComplete);
preload.loadManifest([{id:"imgID",src: filename1},{id:"imgID2",src: filename2}]);
}
function handleFileComplete(event) {
var imgID = preload.getResult("imgID");
var imgBmp = new createjs.Bitmap(imgID);
imgBmp.x = 0;
imgBmp.y = 0;
exportRoot.imageContainer.addChild(imgBmp);
alert(exportRoot.imageContainer.getNumChildren());
//next file loading
var imgID2 = preload.getResult("imgID2");
var imgBmp2 = new createjs.Bitmap(imgID2);
imgBmp2.x = 0;
imgBmp2.y = 300;
exportRoot.imageContainer.addChild(imgBmp2);
alert(exportRoot.imageContainer.getNumChildren());
};
//A button for file loading
this.getManifest.addEventListener("click", fl_MouseClickHandler_getManifest.bind(this));
function fl_MouseClickHandler_getManifest()
{
loadImage("images/pages/Guide-005.jpg","images/pages/Guide-006.jpg");
}
Thanks in advance
Look at this code:
preload.addEventListener("fileload", handleFileComplete);
preload.loadManifest([{id:"imgID",src: filename1},{id:"imgID2",src: filename2}]);
You're listening for the "fileload" event, which fires every time an individual file has been loaded.
Think about what's going to happen when you load two files.
Copy link to clipboard
Copied
Look at this code:
preload.addEventListener("fileload", handleFileComplete);
preload.loadManifest([{id:"imgID",src: filename1},{id:"imgID2",src: filename2}]);
You're listening for the "fileload" event, which fires every time an individual file has been loaded.
Think about what's going to happen when you load two files.
Copy link to clipboard
Copied
Right!
The moral here is that i just have to read the documentation to the end.
I should listen for "complete" event i guess.
Thanks ClayUUID
Find more inspiration, events, and resources on the new Adobe Community
Explore Now