Comunidad de diseño web y desarrollo en internet online

imprimir ruta varieble dentro de un while

Citar            
MensajeEscrito el 29 Abr 2009 07:51 pm
Hola,
Tengo un problema en un while que stoy haciendo. Voy duplicando ua funcion...

while (i <= 9) {
_root["itm_alfabeto"+i].onRelease = function() {
...
}}

esto se salva como:
itm_alfabeto1
itm_alfabeto2
itm_alfabeto3
etc

y funciona, hasta ahi, perfecto. Pero hay una parte del codigo que no puedo reslver.
Quiero salvar las posicion de varios MC dinamicamente, para que cada vez que se duplica la funcion use uno diferente.
El tema es que cuando lo hago, en el trace sale como que esta bien, porque me da las cifras que esperaba, pero me di cuenta que como el numero del movie clip es dinamico en realidad queda siempre el ultimo.
El codigo es el siguiente:

this.targX = this["zona_inicial"+i]._x
this.targY = this["zona_inicial"+i]._y

y me esta salvando siempre

this.targX = this.zona_inicial10._x
this.targX = this.zona_inicial10._y

en vez de

this.targX = this.zona_inicial1._x
this.targX = this.zona_inicial2._x
this.targX = this.zona_inicial3._x
etc.

Ahora, la pregunta seria ¿hay una forma de imprimir el resultado de (this["zona_inicial"+i]._x), dentro del loop?
ej: el resultado de this.targX = this.zona_inicial3._x seria 520.

saludos y gracias

Por stereo-tipo

10 de clabLevel



 

msie7
Citar            
MensajeEscrito el 30 Abr 2009 03:11 am

Código ActionScript :

this["zona_inicial"+i].targX = this["zona_inicial"+i]._x
this["zona_inicial"+i].targY = this["zona_inicial"+i]._y

guardas las variables dentro del mc... si las guardas en el root solo tienes 1 variable y logico queda con el valor de la ultima

trace(this.zona_inicial6.targX);
trace(this.zona_inicial9.targX);

Por nasho

Claber

908 de clabLevel

1 tutorial

Genero:Masculino  

Web Developer

firefox
Citar            
MensajeEscrito el 30 Abr 2009 03:17 pm
Muchas gracias, con tu respuesta lo pude resolver

saludos

Por stereo-tipo

10 de clabLevel



 

msie7

 

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