This is my first as3 project and it’s fairly simple: read in values from an xml file (love that), and then loop through the results. For each result, I want to:
- Attach a movieclip
- Change the text in the clip to match the text in the xml
- Be able to click on the clip and have it echo back the text I just added.
I’ve got this code so far
function boxClick(event:MouseEvent):void {
trace("box clicked");
}
function onLoaded(e:Event):void
{
xml = new XML(e.target.data);
var slideList:XMLList = xml.slides.slide;
var newX:int = 50;
var newY:int = 25;
var slide1:XMLList = slideList[0].options;
//for (var i:int = 0; i < slide1.length(); i++) {
//trace(slide1.option.optionlabel.text());
//}
for (var i:int = 0; i <slide1.option.length(); i++) {
var box:mcAvatar = new mcAvatar();
box.x = newX;
addChild(box);
newX += 100;
trace(slide1.option*.optionlabel.text());
box.gender.text = slide1.option*.optionlabel.text();
trace(box.gender.text);
box.addEventListener(MouseEvent.CLICK, boxClick);
}
}</PHP>
but, although I draw the boxes out and I get the right value in each box's test field, it won't respond to any mouse clicks. What am I doing wrong?