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