Hi!
It’s been a while since my last post…
I just want to share with you my experience with multiple movieClipLoader.
In one of the project that I’m currently working on, I wanted to make a website that would load external modules, made in Flash (of course).
Concept
The concept is the following :
-
When a user load the main site, 8 modules are loaded.
-
Each one of them are loaded with the function attachMovie by creating an instance of a movieClip and gives it the name of the module to load (in a parameter).
-
Each instances load the right swf according to the name of the module passed in parameter using a movieClipLoader.
Problem
While working on my local computer, it seems that some random modules were unable to load on a free server (50free.com). Sometimes it was 1 module that was unable to load, sometimes it was more… However if I made a refresh, everything was fine.
I first suspected the server being slow to respond due to the poor quality of the bandwidth of a free hosting service, so I changed to a faster server that I buyed.
Almost the same problem…
More modules were loading but still not all of them. The problem happened also at random time…
I checked my website on different computer and speed connection and noticed that on a really high-speed (like a cable modem that could download at 500k/s) the problem was not happening. But since not everyone (even I) have this kind of connection…
The solution
I finally found the problem. It seems that there is a maximum number of connection that your modem/computer/Flash/component can handle at the same time. I fixed the problem by putting my loading sequence in a function that requires an index that indicate precisely which module I want to load. I put the function in a setInterval and voila.
Here is the pseudo code:
[AS]
var index = 0;
function loadModule(value){
if(value == 0){
//load module 0
}
if(value == 1){
//load module 1
}
if(value == 2){
//load module 2
}
_root.index++;
if(value > [my maximum number of module]){
clearInterval(loading_sequence);
_root.index = 0;
}
}
loading_sequence = setInterval(loadModule, “100”, index);
[/AS]
I’m not sure that my AS syntax is perfect since I wrote this example by heart… but you understand the principle.
I hope that this will help a few of you who are hardcore programmers who try to load a bunch of stuff at the same moment as I…