I have been at this for awhile now and I am struggling a little bit. I have figured out how to do a for each loop and get text to display in a text field inside a movieclip but I want to do the same thing with an image and seem to be having some trouble. My last question is I have added an event listener inside the loop and can trace it out but how can I target each one of those names since its created after the loop.
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("xmlThumbs.xml"));
function LoadXML(evt:Event):void {
xmlData = new XML(evt.target.data);
ParseNodes(xmlData);
}
function ParseNodes(myInput:XML):void {
//trace(myInput.Photo.title);
var myList:XMLList = myInput.Photo.title;
var newList:XMLList = myInput.Photo.image;
var thumbNail:circle;
var i:uint = 0;
for each (var myElement:XML in myList) {
thumbNail = new circle();
thumbNail.tf_title.text = myElement;
thumbNail.addEventListener(MouseEvent.CLICK, thumbClick);
thumbNail.name = "thumb" + i;
thumbNail.x = 20;
thumbNail.y = 20 + i * 100;
addChild(thumbNail);
i++
}
}
function thumbClick(evt:MouseEvent):void {
trace(evt.target.name);
}
<Books>
<Photo>
<image>thumbs/thumb1.jpg</image>
<title>Photo 1</title>
<intro>Photo 1 Info</intro>
</Photo>
<Photo>
<image>thumbs/thumb2.jpg</image>
<title>Photo 2</title>
<intro>Photo 2 Info</intro>
</Photo>
<Photo>
<image>thumbs/thumb3.jpg</image>
<title>Photo 3</title>
<intro>Photo 3 Info</intro>
</Photo>
<Photo>
<image>thumbs/thumb4.jpg</image>
<title>Photo 4</title>
<intro>Photo 4 Info</intro>
</Photo>
</Books>
Thank you for anyone that can help me I have really be struggling with this and for some reason cant get past it.