# Attaching a movieclip and reacting to a mouse click. Once so easy - now not so much

**URL:** <https://forum.kirupa.com/t/attaching-a-movieclip-and-reacting-to-a-mouse-click-once-so-easy-now-not-so-much/273236>\
**Category:** Uncategorized\
**Created:** [October 13, 2008, 1:52pm UTC](https://forum.kirupa.com/t/attaching-a-movieclip-and-reacting-to-a-mouse-click-once-so-easy-now-not-so-much/273236 "2008-10-13T13:52:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![katyjack](https://avatars.discourse-cdn.com/v4/letter/k/e19b73/32.png) [@katyjack](https://forum.kirupa.com/u/katyjack)\
**Post date:** [October 13, 2008, 1:52pm UTC](https://forum.kirupa.com/t/attaching-a-movieclip-and-reacting-to-a-mouse-click-once-so-easy-now-not-so-much/273236/1 "2008-10-13T13:52:57Z")

</div>

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:

1. Attach a movieclip
2. Change the text in the clip to match the text in the xml
3. Be able to click on the clip and have it echo back the text I just added.

I’ve got this code so far

```php

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 &lt; slide1.length(); i++) {
        //trace(slide1.option.optionlabel.text());
    //}
    
    for (var i:int = 0; i &lt;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);
      }
}&lt;/PHP&gt;

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?
```
