2 Replies Latest reply on Nov 19, 2017 1:30 PM by popolino17

    LoadManifest multiplies the added objects

    popolino17

      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