Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

LoadManifest multiplies the added objects

Explorer ,
Nov 19, 2017 Nov 19, 2017

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

459
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Nov 19, 2017 Nov 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.

Translate
LEGEND ,
Nov 19, 2017 Nov 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Nov 19, 2017 Nov 19, 2017
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines