PDA

View Full Version : publishing settings, components and listeners


mary_poppins
07-24-2006, 11:01 AM
Hello

I am having a few problems with trying to make my components talk to each other, the confusing thing about the issue is that the code works as expected the first time it is executed. I have four custom button components that dispatch a "change" event, and a quiz component that has listeners and the change function, here is the code that adds the listeners to the components:


private function populateCmpArray():Array {
var a:Array = new Array();
var f:Number = 0;
for (var i in _mtl) {
var ref:String = i.split("_", 1)[0];
if (ref == "cmp") {
_mtl[i].index = f;
a.push(_mtl[i]);
trace(a);
_mtl[i].addEventListener("change", this);
f++;
}
}
return a;
}


On the first frame of my fla the event relay works as expected, but when I move to the second frame and call populateCmpArray() again the components are added to the array but the listeners don't get added, does anyone know what's going on?

Thanks