I'm having a weird situation that only seems to occur in IE. I have a setup in my my AS2 flash app to load an arbitrary number of different sounds, but with an limit on the number of sounds being loaded simultaneously.
It works like this: It starts loading up to the first, say, 5 sounds, and then after each one finishes loading, it starts loading the next sound in the queue. Psuedocode:
arrayOfURLs = ["a.mp3", "b.mp3", "c.mp3", ...etc...];
arrayOfSounds = ;
nextToLoad = 0;
var limit = 5;
var numberToStart = min(limit, arrayOfURLs.length);
nextToLoad = numberToStart;
for(i=0; i<arrayOfURLs.length; i++)
arrayOfSounds[i] = new Sound();
arrayOfSounds[i].onLoad = callback;
if(nextToLoad < arrayOfURLs.length)
It works fine on everything except IE. And it will work on IE as long as the files aren't cached. But if they are cached, then in IE (and only in IE) the flash app will hang and produce a trace like this:
And after roughy 50 of those "start callback"s the flash app hangs and it never gets to any "end callback" or "c".
It seems that loadSound is deciding to call onLoad synchronously, instead of asynchronously as would normally be expected. But this never seems to happen in anything but IE, even when the given browser has it all cached. So apparently it's either calling onLoad the wrong way in IE, or flash events like onLoad are susceptible to race conditions and need to be written accordingly.
Can anyone shed any light on this?
FWIW, I seem to be able to work around the problem by calling Sound.loadSound on a small (10ms) timer delay. But I'd like to know if anyone can tell me more about this. (Also, I apologize for just having psuedocode and not real sample code to run, but I'm kinda swamped ATM and haven't had time to put together a minimal test case. Again, sorry about that.)
A related question: In AS2, do I need to worry about thread-safety?
As an example, suppose I start loading a bunch of sounds via Sound.loadSound, and give them all the same onLoad callback. This callback happens to be:
// Do stuff
Is the output of that guaranteed to be "ABABAB..."? Or it is possible that two sounds might call onLoad at the same time and you end up with a race condition: "AABB"?