Add a child inside a newly created instance, inside of a loop in AS3
- by HeroicNate
I am trying to create a gallery where each thumb is housed inside of it's own movie clip that will have more data, but it keeps failing because it won't let me refer to the newly created instance of the movie clip. Below is what I am trying to do.
var xml:XML;
var xmlReq:URLRequest = new URLRequest("xml.xml");
var xmlLoader:URLLoader = new URLLoader();
var imageLoader:Loader;
var vidThumbn:ThumbNail;
var next_y:Number = 0;
for(var i:int = 0; i < xml.downloads.videos.video.length(); i++)
{
vidThumbn = new ThumbNail();
imageLoader = new Loader();
imageLoader.load(new URLRequest(xml.downloads.videos.video[i].ThumbnailImage));
vidThumbn.y = next_y;
vidThumbn.x = 0;
next_y += 117;
imageLoader.name = xml.downloads.videos.video[i].Files[0].File.URL;
videoBox.thumbList.thumbListHolder.addChild(vidThumbn);
videoBox.thumbList.thumbListHolder.vidThumbn.addChild(imageLoader);
}
It dies every time on that last line. How do I refer to that vidThumbn instance so I can add the imageLoader? I don't know what I'm missing. It feels like it should work.