# Attach events to multiple MCs...again

**URL:** <https://forum.kirupa.com/t/attach-events-to-multiple-mcs-again/208070>\
**Category:** flash\
**Created:** [November 24, 2006, 4:56pm UTC](https://forum.kirupa.com/t/attach-events-to-multiple-mcs-again/208070 "2006-11-24T16:56:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![kalaxan](https://avatars.discourse-cdn.com/v4/letter/k/f07891/32.png) [@kalaxan](https://forum.kirupa.com/u/kalaxan)\
**Post date:** [November 24, 2006, 4:56pm UTC](https://forum.kirupa.com/t/attach-events-to-multiple-mcs-again/208070/1 "2006-11-24T16:56:10Z")

</div>

I have created a map (1 frame movie) at Flash MX 2004, that each area is a movieclip. Each movieclip has a unique name. I am trying to dynamically attach events to each movieclip, by reading their corresponding names from an XML file, with the following code:

```auto

areas_xml = new XML();
areas_xml.onLoad = initAreaBtns;
areas_xml.load("map_data.xml");
areas_xml.ignoreWhite = true;

function initAreaBtns(success) {
    if (success == true) {
        areasRoot = areas_xml.firstChild;
        areasNum = areasRoot.childNodes.length;
        
        for(i=0;i<areasNum;i++){
            area_mc = eval(areasRoot.childNodes*.attributes.areaKeyName);
            
            area_mc.onRollOver = function(){
                var col = new Color(area_mc._name);
                col.setRGB(0xff9900);
            }
            area_mc.onRollOut = function(){
                var col = new Color(area_mc._name);
                col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0})
            }
        }
    }
}

```

As you can see I am trying to create a roll over effect for each area/movieclip. The problem is that only the last movieclip is affected.

Any ideas?
