Comunidad de diseño web y desarrollo en internet online

Conocer variable de funcion fuera de la funcion.

Citar            
MensajeEscrito el 28 Sep 2008 09:26 am
Es posible conocer el valor de una variable generada dentro de la función <onLoad> de <LoadVars>, desde fuera de la función?
Veréis, tengo necesidad de utilizar los valores que adquiere un campo de texto, que relleno mediante <LoadVars>, fuera de la función <onLoad>, algo así:

Código :

listAlmac_mc.texto_txt.autoSize = true;

var list_lv:LoadVars = new LoadVars ();

list_lv.onLoad = function (exito) {
   if (exito) {

      listAlmac_mc.texto_txt.htmlText += "<br>";
      listAlmac_mc.texto_txt.htmlText += this.rec;
      listAlmac_mc.texto_txt.htmlText += this.alm;
      listAlmac_mc.texto_txt.htmlText += this.pre;

      listAlmac_mc.marco_mc._height = listAlmac_mc.texto_txt._height + 20;
      listAlmac_mc.marco_mc._width = listAlmac_mc.texto_txt._width + 20;
trace (listAlmac_mc.texto_txt._height);
   }
};

list_lv.load ("textos/mensajes.txt");

trace (listAlmac_mc.texto_txt._height); 

El trace de dentro de <onLoad>, me devuelve la altura que adquiere el campo en función de las variables que carga,
pero el trace de fuera, siempre me devuelve la altura inicial del campo. Como puedo conocer desde fuera el valor real de la altura del campo.

Por antonio_L

161 de clabLevel



Genero:Masculino  

de Linares

firefox
Citar            
MensajeEscrito el 28 Sep 2008 11:15 am

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox
Citar            
MensajeEscrito el 29 Sep 2008 08:44 am
Gracias por la aclaración, aunque para llamar a la función <beginApplication()> desde botones tenga que poner el <onRelease> de los mismos dentro de <onLoad>.
Podría querdar así:

Código :

listAlmac_mc.texto_txt.autoSize = true;
listTrans_mc.texto_txt.autoSize = true;

listAlmac_mc.setMask (mask_mc);
listTrans_mc.setMask (mask1_mc);

var list_lv:LoadVars = new LoadVars ();

list_lv.onLoad = function (exito) {
   if (exito) {

      listTrans_mc.texto_txt.htmlText += "<br>";
      listTrans_mc.texto_txt.htmlText += "- " + this.pa;
      listTrans_mc.texto_txt.htmlText += "- " + this.co;
      listTrans_mc.texto_txt.htmlText += "- " + this.gr;
      listTrans_mc.texto_txt.htmlText += "- " + this.ca;
      listTrans_mc.texto_txt.htmlText += "- " + this.me;
      listTrans_mc.texto_txt.htmlText += "- " + this.pl;
      listTrans_mc.texto_txt.htmlText += "- " + this.en;
      listTrans_mc.texto_txt.htmlText += "- " + this.sa;

      listAlmac_mc.texto_txt.htmlText += "<br>";
      listAlmac_mc.texto_txt.htmlText += this.rec;
      listAlmac_mc.texto_txt.htmlText += this.alm;
      listAlmac_mc.texto_txt.htmlText += this.pre;

      listAlmac_mc.marco_mc._height = listAlmac_mc.texto_txt._height + 20;
      listAlmac_mc.marco_mc._width = listAlmac_mc.texto_txt._width + 20;

      listTrans_mc.marco_mc._height = listTrans_mc.texto_txt._height + 20;
      listTrans_mc.marco_mc._width = listTrans_mc.texto_txt._width + 20;

      btn_mc.onRelease = function () {
         beginApplication (listAlmac_mc,mask_mc);
      };

      btn1_mc.onRelease = function () {
         beginApplication (listTrans_mc,mask1_mc);
      };
   }
};

list_lv.load ("textos/mensajes.txt");

function beginApplication (mc, mas):Void {
   mas._height = mc.marco_mc._height;
   mas._width = mc.marco_mc._width;
   mas._x = mc._x;
   mc._y = mas._y - mas._height;
}

Gracias

Por antonio_L

161 de clabLevel



Genero:Masculino  

de Linares

firefox
Citar            
MensajeEscrito el 29 Sep 2008 02:11 pm
Pues claro, si las acciones de los botones dependen del resultado del XML, debes darle las acciones dentro del onLoad del mismo o dentro del onLoad ejecutar una función que le de las acciones a los mismos, como quieras.

Por elchininet

Claber

3921 de clabLevel

17 tutoriales

Genero:Masculino  

Front-end developer at Booking.com

firefox

 

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