The loadScripts function should keep track of the scripts that have finished loading by removing them from the loadingFiles array. The problem is, that the changes made to the array in one call to the local function fileLoaded won't show up in the next call (no elements are ever deleted). I suspect this has something to do with scoping rules, but I can't quit get a grip on it.

I would really appreciate any help.

08-26-2010, 05:14 PM

rnd me

files.slice() makes a new copy of the array.
loadingFiles = files; would share a common array among all instances.

08-27-2010, 04:40 AM

Codecaster

Quote:

Originally Posted by rnd me

files.slice() makes a new copy of the array.
loadingFiles = files; would share a common array among all instances.

I know. I actually want a copy. Otherwise the fileLoaded callback would delete elements from the array while possibly still looping through it. All of the calls to fileLoaded should still be able to work with the same copy though.

There is something reallly fishy about this. I eventually got it to work by changing the names of the 'onLoad' function arguments. Obviously this should not make any difference at all. Anyway, I can't afford to dwell on it for too long, but it left me confused.