Hi SJM, It looks like you're setting the persistent var, _mcName, to equal each _summaryElement[i].sumImg in turn as the loop progresses. That means that when the loop is finished, the value for _mcName will be a reference to _summaryElement[4].sumImg, the last clip being loaded. Since your loop undoubtedly runs faster than the loading process, what your imgLoadComplete handler is actually doing is this, _summaryElement[4].sumImg.addChild(ev.target.content). It wouldn't be surprising if you looked at the contents of _summaryElement[4].sumImg and found that all the images are added to its display list as each load completes. I would either get rid of the persistent var and find a way to use an ID number to link the loaded images and the containers, OR add this line to your loadImage method, _mcName.addChild(imageLoader);, and forget the event listener (at least for doing the addChild).
Hth, Bob -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: Tuesday, May 06, 2008 9:54 AM To: flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] AS3 For loop proplem This code should load a MovieClip from the library 5 times, place each on the stage and then load a different image into each one Instead it loads the 5 MovieClips from the library, places them on the stage and then only loads the image into the last (5th) MovieClip, whats going wrong? !!!! this code will not run as its stripped !!!! var itemList:XMLList = locationInfo.item; for (var i = 0; i < itemList.length(); i++) // Loops through 5 times { _summaryElement[i] = loadLibrary(summaryContainer); // Load our MovieClip from the library loadImage("images/" + i + ".jpg", _summaryElement[i].sumImg); // Should load image into _summaryElement[i].sumImg which is a blank placeholder movieclip } function loadImage(filename:String, mcName:MovieClip):void { _mcName = mcName; // Contains MovieClip object (object 1 through 5) var imageLoader:Loader = new Loader(); var imageURL:URLRequest = new URLRequest(filename); imageLoader.load (imageURL); imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imgLoadComplete); } function imgLoadComplete(ev:Event):void { _mcName.addChild(ev.target.content); // This should add the loaded image into the placeholder movieclip for each of the 5 MovieClips } SJM _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders _______________________________________________ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders