MovieClipLoader only loading first picture

MovieClipLoader only loading first picture

Post by cinemagu » Sun, 14 Jan 2007 07:08:55


Well i feel retarded but I cannot figure out why this code is only loading the
first picture from the array. Everything is loaded properly but it is only
tracing out the first number of the array. Any ideas?

var numOfImages:Number = xmlHref.length;
var preloadCount:Number = 0;
var theLoader:MovieClipLoader = new MovieClipLoader();
var theListener:Object = new Object();
theLoader.addListener(theListener);
theListener.onLoadInit = function(mc:MovieClip) {
trace(preloadCount);
_root["bitmapPic" + i] = new BitmapData(mc._width, mc._height);
_root["bitmapPic" + i].draw(mc);
mc.removeMovieClip();
_root.m_images.attachMovie("m_empty", "image" + i, i + 50);
_root.m_images["image" + i]._x = preloadCount * 100;
_root.m_images["image" + i].attachBitmap(_root["bitmapPic" + i], i + 1000);
_root.m_images["image" + i]._xscale = 10;
_root.m_images["image" + i]._yscale = 10;
preloadCount++;
};
for (var i = 0; i < numOfImages; i++) {
_root.createEmptyMovieClip("tempMC", 5, {_alpha:0});
theLoader.loadClip(xmlHref[i], _root.tempMC);
}
 
 
 

MovieClipLoader only loading first picture

Post by sly on » Sun, 14 Jan 2007 14:55:26

Hard to tell without seeing how you create the xmlHref array. Have you tried
tracing the array's contents from within the for loop? I would add a couple of
traces in there and see if what you get is what you expect:

for (var i = 0; i < numOfImages; i++) {
trace("numOfImages="+numOfImages);
trace("xmlHref="+xmlHref);
_root.createEmptyMovieClip("tempMC", 5, {_alpha:0});
theLoader.loadClip(xmlHref[i], _root.tempMC);
}

 
 
 

MovieClipLoader only loading first picture

Post by IwannaFlas » Sun, 14 Jan 2007 23:25:56

erm........I see three things that raise my somewhat limited eyebrows:

1. You define the onLoadInit function AFTER adding the listener to
theLoader......don't know if that matters or not.

2. Variables within functions are separate from variables outside of said
functions, unless you pass them to the function during the call or use a
pathing scheme.......so how does the "i" in your onLoadInit function equal the
"i" in your for loop?

3. Finally, in your for loop, you keep creating the SAME empty movie clip,
with the SAME name and the load a picture into that movie clip. If I am reading
that code right, what you should see (assuming the other two points are
meaningless) is last picture loaded only, as pic1 will be replaced by pic2
which will be replaced by .... last pic.

If you are seeing the first pic, then my guess is the problem is #2. If you
are seeing the last pic, then the problem is #3.

These are my guesses and I'm sticking to them! :p