Skip to main content
albertd9194959
Inspiring
January 12, 2018
Answered

Animate preloadJS "setMaxConnections" complications HTML/Javascript

  • January 12, 2018
  • 1 reply
  • 679 views

Hi All,

I have added the following to the default exported content from animate in order to greatly speedup content pre-loading: PreloadJS API

loader.setMaxConnections(10);

loader.maintainScriptOrder = true;

The problem i have is that the "handleComplete" triggers before all the content has been downloaded. ( This problem gets worse when you emulate a slow network connection ) So the animate content starts even though its still downloading required images.

There are a few ways of doing this, but require overriding the way the default animate handleComplete ( see bellow ) works.

loader.addEventListener("complete", function(evt){handleComplete(evt,comp)});

As in adding array/loop that adds .complete / .onload to the images in the manifest and then overrides the complete function once they have all downloaded.

Edit: Possibly within animate:

this.stop on frame 1.....create another "EventListener", detect once all library/stage elements are loaded....this.play....

Thanks !!

This topic has been closed for replies.
Correct answer Colin Holgate

I have used:

loader.setMaxConnections(6);

a lot, and not had loading problems. I haven't used loader.maintainScriptOrder = true; though, I wonder if that could be the problem?

BTW, I use (6) and not (10) because I tested all browsers, and many cases only went up to 6. The best case was Internet Explorer, it can do 11 at the same time, which, as you know, is one louder than 10.

1 reply

Colin Holgate
Colin HolgateCorrect answer
Inspiring
January 12, 2018

I have used:

loader.setMaxConnections(6);

a lot, and not had loading problems. I haven't used loader.maintainScriptOrder = true; though, I wonder if that could be the problem?

BTW, I use (6) and not (10) because I tested all browsers, and many cases only went up to 6. The best case was Internet Explorer, it can do 11 at the same time, which, as you know, is one louder than 10.

albertd9194959
Inspiring
January 15, 2018

Ah, thanks for the input Colin, ill definitely reduce the amount for now.

I'm still doing some testing with regards to really slow/interrupted network connections, for a simple work-around, I'll maybe check network speeds and reduce the Max Connection amount....

Edit:

Looking at how animate sets everything up for load, it doesn't seem like maintainScriptOrder will actually do anything as the manifest file only loads images. ( Force adding JS files to the manifest didn't seem effect the load order either).

Thanks !

Colin Holgate
Inspiring
January 15, 2018

I would just stick with 6. 6 at a time on a slower connection is still useful.