peterworth
Programmer
i'm not sure how scope works in actionscript - am i doing something wrong in the code below?
the loop runs 3 times, so there should be 3 movieclip loader objects and 3 listeners. but in the output, there is only 1 "loaded" trace. i.e. only one of the listener objects has called the onLoadInit function.
any advice appreciated!
the loop runs 3 times, so there should be 3 movieclip loader objects and 3 listeners. but in the output, there is only 1 "loaded" trace. i.e. only one of the listener objects has called the onLoadInit function.
any advice appreciated!
Code:
trace("length "+content_xml.firstChild.childNodes.length);
for (var i = 0; i < content_xml.firstChild.childNodes.length; i++) {
var lo = new Object();
var mcl = new MovieClipLoader();
createEmptyMovieClip("floorplan"+i, this.getNextHighestDepth());
mcl.addListener(new Object());
lo.onLoadInit = function() {
trace("loaded");
floorplans[i]._width = floorplanWidth;
floorplans[i]._height = floorplanHeight;
floorplans[i]._x = offStageRight;
floorplans[i]._y = floorplanY;
};
trace("loading "+content_xml.firstChild.childNodes[i].attributes.image);
mcl.loadClip(content_xml.firstChild.childNodes[i].attributes.image, eval("floorplan"+i));
}