Ver Mensaje Individual
  #1 (permalink)  
Antiguo 29/07/2009, 10:15
abigor66
 
Fecha de Ingreso: mayo-2008
Mensajes: 489
Antigüedad: 16 años
Puntos: 8
Pregunta como nombrar mc utilizando un bucle??

Buenos días Foreros, nuevamente por acá. esta vez con algo de actionScript. Resulta que estoy llamando un xml de manera dinámica, pero su contenido se debe mostrar en cajas d texto dinámico independientes, el problema es que son muchas y sería bueno hacer el empalme utilizando actionscript. este es el código de ejemplo:

Código actionscript:
Ver original
  1. my_xml = new XML();
  2. my_xml.load("sample.xml");
  3. my_xml.onLoad = my_function;
  4. my_xml.ignoreWhite = 1;
  5.  
  6. function my_function() {
  7.     text_0.text = my_xml.firstChild.childNodes[0].attributes.product_name;
  8.     text_1.text = my_xml.firstChild.childNodes[1].attributes.product_name;
  9.     text_2.text = my_xml.firstChild.childNodes[2].attributes.product_name;
  10.    
  11.     field_0.text = my_xml.firstChild.childNodes[0].attributes.price;
  12.     field_1.text = my_xml.firstChild.childNodes[1].attributes.price;
  13.     field_2.text = my_xml.firstChild.childNodes[2].attributes.price;
  14. }

la idea es presentar la información en forma de tabla, en este ejemplo hay dos columnas y yo voy a necesitar 4 peo eso no es problema si me ayudan a solucionar lo que pregunto.

lo que me interesa hacer es algo así:

Código actionscript:
Ver original
  1. my_xml = new XML();
  2. my_xml.load("sample.xml");
  3. my_xml.onLoad = my_function;
  4. my_xml.ignoreWhite = 1;
  5.  
  6. function my_function() {
  7.     for( var i:Number = 0; i <= 3; i++ ) {
  8.         "text_"+i.text = my_xml.firstChild.childNodes[i].attributes.product_name;
  9.     };
  10.    
  11.     for( var i:Number = 0; i <= 3; i++ ) {
  12.         "field_"+i.text = my_xml.firstChild.childNodes[i].attributes.product_name;
  13.     }
  14. }

gracias por su tiempo y espero me puedan ayudar.

PD: el código que puse al final da error y es lo que quiero solucionar