Skip to main content
Known Participant
November 19, 2017
Answered

LoadManifest multiplies the added objects

  • November 19, 2017
  • 1 reply
  • 518 views

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

This topic has been closed for replies.
Correct answer ClayUUID

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.

1 reply

ClayUUIDCorrect answer
Legend
November 19, 2017

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.

Known Participant
November 19, 2017

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