Comunidad de diseño web y desarrollo en internet online

Instancias dinamica & htmlText dinamica

Citar            
MensajeEscrito el 09 Mar 2011 04:32 am
Un cordial saludos a todos, tengo el siguiente problemita.

Quiero generar dinámicamente o por un for lo siguiente:

Código ActionScript :

 MC_tx1.tx_1.htmlText = text0;
MC_tx2.tx_2.htmlText = text1;
MC_tx3.tx_3.htmlText = text2;
.........

de esa manera hasta el 80 + o -
El asunto es que no quiero estar creando una a una y es por eso que estaba intentando hacer algo como esto.

Código ActionScript :

var h;
   h=1;
   for(var i : int=0;i<80;i++){
      this["text"+i] = xmlList[i];
   }
   for(var j : int=0;j<80;j++){
      this["MC_tx"+h]."tx_"+h.htmlText = this["text"+j];
      trace(j);
      h++;   
}


Y de distintas manera lo probe:

Código ActionScript :

this["MC_tx"+h].["tx_"+h].htmlText = this["text"+j];
this["MC_tx"+h+".tx_"+h].htmlText = this["text"+j];
........


Y muchas otras mas y nada :( quería saber si me pueden ayudar con esto, soy un principiante con el actionscript y he estado dando muchas vueltas en la red y no consigo nada.

Por uman777

1 de clabLevel



 

chrome
Citar            
MensajeEscrito el 09 Mar 2011 10:59 am
Puedes meterlo en un array ...

Código ActionScript :

var textos:Array = new Array();
for(var i : int=0;i<80;i++){ 
      textos.push(xmlList[i]); 
   } 


Luego en el segundo loop la forma correcta es:

this["MC_tx"+j].["tx_"+j].htmlText = textos[j];

Recuerda que en el segundo loop el contador es j y no i

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 09 Mar 2011 11:37 am
Porque dos loops?

Código ActionScript :

var NUMERO_DE_TEXTOS : uint = 50;
for(var i : int = 0; i< NUMERO_DE_TEXTOS; i++)
{ 
      this["text" + i] = xmlList[i]; 
      this["MC_tx" + i]["tx_" + i].htmlText = xmlList[i]; 
}


Y 'text'+i es necesario? quiza no ;)

Por Acreonte

Claber

1543 de clabLevel

5 tutoriales
6 articulos

Genero:Masculino  

Digital Scientist

firefox
Citar            
MensajeEscrito el 09 Mar 2011 12:35 pm
Saludos.! muchas gracias por su pronta respuesta he logrado solucionar el problema.

Código ActionScript :

   var j:int = 1;
   var NUMERO_DE_TEXTOS:uint = 80;
   for (var i : int = 0; i< NUMERO_DE_TEXTOS; i++)
   {
      this["text" + i] = xmlList[i];
      this["MC_tx" + j]["tx_" + j].htmlText = xmlList[i];
      j++;
   }
}

De esa manera me quedo el código, ahora si funciona

:lol:

Gracias por la ayuda.!

Por uman777

1 de clabLevel



 

chrome
Citar            
MensajeEscrito el 09 Mar 2011 02:10 pm
Hardcodear la cantidad no es buena idea, ya que si cambia la cantidad que pones en el XML, estarás perdiendo información o mostrando campos a null

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.