Código ActionScript :
var nombres = new Array();
var colores = new Array();
var nodos_total:Number;
var arichoXML:XML = new XML();
arichoXML.ignoreWhite = true;// -- ignorar espacios
arichoXML.onLoad = function(succes){// -- proceso si la carga tuvo éxito
if(succes){
var nodos:Array = this.firstChild.childNodes;
nodos_total = nodos.length;
if(nodos_total > 0){
for(i=0; i < nodos.length; i++){
nombres[i] = nodos[i].childNodes[0].firstChild;
colores[i] = nodos[i].childNodes[1].firstChild;
color = new Color(_root["mc_c" + i ]);
t_col = "0x" + colores[i];
color.setRGB( t_col );
_root["txt" + i ].text = nombres[i];
[b] _root["mc_c" + i ].onRelease = function(){
_root["txtcodigo"].text = t_col;
trace("mc_c" + i );
}[/b]
}
} else {
trace("No se han encontrado imagenes.");
}
} else {
trace("Error al Leer archivo XML");
}
};
// -- cargar XML
arichoXML.load("xml.xml");
Código ActionScript :
_root["mc_c" + i ].onRelease = function(){
_root["txtcodigo"].text = t_col;
trace("mc_c" + i );
}
Creo que mi error es meter esta funcion dentro del for ya que al ejecutar y al hacer clic al MC siempre me muestra el último item del xml. Hay alguna otra solución?, espero me puedan ayudar. Gracias.
