I'm loading a bunch of images into my AS2 flash movie, and I've encountered some strangeness.
Roughly, my code looks like this:
function doTheLoading()
{
m_imageClips = [];
for (var i:Number = 0; i < 3; i++)
{
var imageUrl:String = "http://server/" + i + ".jpg";
var mc :MovieClip = m_mc.createEmptyMovieClip("name"+i, i + 1);
m_imageClips.push( mc );
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip(imageUrl, mc);
}
myDebug("array1: "+m_imageClips);
}
function onLoadComplete(mc:MovieClip)
{
myDebug("array2: " + m_imageClips );
myDebug("type: " + typeof(m_imageClips[0]) );
for (var i:Number = 0; i < m_imageClips.length; i++)
{
if (mc == m_imageClips[i])
{
/* This line is never reached. */
}
}
}
And the output looks something like
array1: mc.0.jpg, mc.1.jpg, mc.2.jpg
array2: ,,
type: movieclip
array2: ,,
type: movieclip
array2: ,,
type: movieclip
So my question is why does my array content seem to change when in the onLoadComplete call? If the array is out of scope, then why can I still see the length of the array and determine the type of the contents?