Comunidad de diseño web y desarrollo en internet online

embedFonts para varios campos

Citar            
MensajeEscrito el 27 Feb 2007 07:00 pm
Saludos.

Tengo esto de manera normal y funciona:

var style:TextFormat = new TextFormat();
style.font = "fuente1";
campos.embedFonts = "true";
campos.setTextFormat(style);


Pero tengo varios campos de texto y no quiero tener esas largas tiras de código, entonces como podría ser posible aplicar este style a varios campos de texto?

Gracias.

JOHNMARTIN

Por JOHNMARTIN

Claber

1222 de clabLevel

4 tutoriales
4 articulos
2 ejemplos

Genero:Masculino  

||| BOGOTA COLOMBIA |||

firefox
Citar            
MensajeEscrito el 25 Sep 2007 10:14 pm
uff, yo tengo el mismo problema. El codigo es muy simple pero se alarga mucho cuando tienes varios campos de texto. Debe ser muy parecido para resumir este codigo:

Código :

with (mc_animado.txtInfo) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtTitle) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtName) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtArea) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtPopulation) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtCapital) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtPeople) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtLanguage) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtReligion) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtIndustry) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtClimate) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtVisas) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtExchange) {
   depthChild0._alpha=0;
   visible = false;
}
with (txtBank) {
   depthChild0._alpha=0;
   visible = false;
}


Si alguien se anima a dar una respuesta ya somos 2 los beneficiados.

Gracias amigos[/quote][/code]

Por Polako

6 de clabLevel



 

firefox
Citar            
MensajeEscrito el 25 Sep 2007 11:02 pm
Bueno, para ambos. Digamos que tenemos todos estos campos de texto en la línea de tiempo principal. Entonces pasa que, además de los campos de texto también tenemos botones, movieclips, etc. Podríamos hacerlo con un bucle for...in:

Código :

for(var texto:String in this){  //'this' en este caso apunta a '_root'
    if(this[texto] instanceof TextField){ //Verificamos que estamos tratando con un Campo de Texto
         this[texto].propiedad_a_cambiar = valor; //Cambiamos la(s) propiedad(es) que nos interesa(n)
   }
}


Este bucle se ejecutará en todos los objetos de '_root'
Si no está en la línea de tiempo principal sino, digamos, dentro de un clip de película, colocamos este mismo código dentro de la línea de tiempo del clip de película.

Por The Fricky!

Presidente

6168 de clabLevel

3 tutoriales
8 articulos

Genero:Masculino   Bastard Operators From Hell Héroes

Piccola Venezia...

firefox
Citar            
MensajeEscrito el 01 Oct 2007 01:52 pm
tambien pueden poner las instancia de los campos en un arreglo, y usar un for:

Código :

var style:TextFormat = new TextFormat();
style.font = "fuente1";

arrCampos = [mc_animado.txtInfo, txtTitle, txtName, txtArea, txtPopulation, txtCapital, txtPeople, txtLanguage, txtReligion, txtIndustry, txtClimate, txtVisas, txtExchange, txtBank]; // no usar comillas, ya que se guardan las instancias directamente, no los nombres
// tambien se pueden poner instancias dentro de otro movieclip...
for (i=0; i <= arrCampos.length; i++) {
   with (arrCampos[i]) {
      depthChild0._alpha=0;
      visible = false;
      embedFonts = "true";
      setTextFormat(style);
   }
}

Por gabynufe

Claber

446 de clabLevel



 

México, D.F.

msie7

 

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