XML for loop issue

Hi all,

I’m trying to pull a set of thumbnails from an XML file, and then get it to display on the page.

I’ve got a simple for loop set up to handle the function, but whenever I test the file only the last image shows up. But it shows up in the correct location (where it would if it were surrounded by other images). It’s like flash is creating a spot for the images, just not attaching them…I’ve also tried adding a mouseover listener to see if anything was getting added to their spots, and no, nothing.

I’ve done some tests (changing how many times the loop runs, etc.) and I know that flash recognizes all the images, and the paths are right, it just refuses to show more than one.

Thanks,
Any help would be greatly appreciated.

private function loadThumbs():void
		{
			trace("loadThumbs Called");
			for (c = 0; c < totalPics; c++)
			{
			thumbRequest = new URLRequest (thumbPathList[c]);
			thumbLoader.load(thumbRequest);
			
			trace("thumbRequests: " + thumbRequest);
			trace("thumbPathC: " + thumbPathList[c]);
			
			all_thumbs.addChild(thumbLoader);
			
			thumbLoader.x = (xs * xSpacing) + 8 ;
			thumbLoader.y = (ys * ySpacing) + 5 ;
			xs = xs + 1;
			if ( xs == thumbRowCount ) 
			{// if the row has reached the max thumbs per row, then this starts a new row.
				xs = 0;
				ys = ys + 1;
			}
			trace("TLX: " + thumbLoader.x);
			trace("TLY: " + thumbLoader.y);
			}
			thumbLoader.addEventListener(MouseEvent.CLICK, loadMainPic );
			thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbsLoaded);
		}

It looks as though you’re using the same loader over and over again, which means the previous contents will be overwritten with the next image. That’s why you’re only getting to see the last image. (It’s the only one that doesn’t get overwritten.)

Either use a different loader for each image (probably best to do that by having an array of loaders), OR, use a single loader, like you have done, but once an image has finished loading, ‘take it out’ of the loader by copying the contents to a movieclip created for that purpose, and placing that movieclip where you want the image to appear on stage.

Hope that helps.