Comunidad de diseño web y desarrollo en internet online

Aplicar estilos CSS a texto importado con LoadVars

Citar            
MensajeEscrito el 01 May 2008 07:25 pm
Hola de nuevo,
tengo un pequeño lío con el ActionScript para aplicar un estilo CSS a un texto importado con la función LoadVars(). He tomado dos ejemplos que han puesto a disposición del público la gente de Cristalab, pero al juntarlos, creo que lo he hecho mal :oops: .

Código del FLA: (tomado de http://www.cristalab.com/tutoriales/13/sistema-de-noticias-en-flash-con-loadvars)

Código :

var myCSS = new TextField.StyleSheet();
var cssURL = \\\\\\\"style.css\\\\\\\";
myCSS.load(cssURL);
myCSS.onLoad = function(exito) {
   if (exito) {
      myTexto2.styleSheet = myCSS;
   }
};
Obj2 = new LoadVars();
Obj2.load(\\\\\\\"data1.txt\\\\\\\");
myTexto2.htmlText = \\\\\\\"Cargando...\\\\\\\";
Obj2.onLoad = function() {
   titulo = Obj2.titulo.split(\\\\\\\"@@@\\\\\\\");
   descripcion = Obj2.descripcion.split(\\\\\\\"@@@\\\\\\\");
   fuente = Obj2.fuente.split(\\\\\\\"@@@\\\\\\\");
   separador = \\\\\\\"----------------------------------------------------------\\\\\\\";
   myTexto2.htmlText = \\\\\\\"\\\\\\\";
   for (var i = 0; i<titulo.length; i++) {
      myTexto2.htmlText += \\\\\\\"<p class=\\\\\\\'titulo\\\\\\\'>\\\\\\\"+titulo[i]+ \\\\\\\"</p>\\\\\\\"+\\\\\\\"<br>\\\\\\\"+descripcion[i]+\\\\\\\"<br><br>\\\\\\\"+\\\\\\\"<i>\\\\\\\";
   }
};



Código del CSS: (tomado de http://www.cristalab.com/tutoriales/192/usar-css-en-flash)

Código :

@charset \\\\\\\"utf-8\\\\\\\";
/* CSS Document */

p {
  color: #FFFFFF;
  font-family:Arial, Helvetica, sans-serif;
  font-size: 10px;
}
.titulo {
  color: #0000FF;
  font-family: Arial,Helvetica,sans-serif;
  font-size: 18px;
  font-weight: bold;
  display: block;
}



Agradecería mucho un poco de ayuda para resolver este lío monumental que me he hecho :) :oops:

Por DavidDave

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 02 May 2008 01:58 am
Aplica el estilo después de setear el texto

Jorge

Por solisarg

BOFH

13669 de clabLevel

4 tutoriales
5 articulos

Genero:Masculino   Bastard Operators From Hell Premio_Secretos

Argentina

firefox
Citar            
MensajeEscrito el 02 May 2008 01:02 pm
Vaya,.. me temo que no funciona. Es posible que sea un lío sin solución. :cry:

Por DavidDave

6 de clabLevel



Genero:Masculino  

firefox
Citar            
MensajeEscrito el 02 May 2008 01:35 pm
Vale, ¡lo he conseguido! :D :D
Para aquellos que quieren saber como lo solucioné (al final pasé de usar el CSS), les dejo el código:

Código :

Obj2 = new LoadVars();
Obj2.load(\"data1.txt\");
myTexto2.htmlText = \"Cargando...\";
Obj2.onLoad = function() {
   titulo = Obj2.titulo.split(\"@@@\");
   descripcion = Obj2.descripcion.split(\"@@@\");
   fuente = Obj2.fuente.split(\"@@@\");
   separador = \"----------------------------------------------------------\";
   myTexto2.htmlText = \"\";
   myTexto2.htmlText = \"<font face=\'Arial\' size=\'11\' color=\'#FFFFFF\'><b>Bienvenidos a mi web</b></font>\"
   for (var i = 0; i<titulo.length; i++) {
      myTexto2.htmlText += \"<font face=\'Arial\' size=\'10\' color=\'#FFFFFF\'>\"+descripcion[i]+\"<br><br>\"+\"<i>\"+\"</font>\"
   }
};

Por DavidDave

6 de clabLevel



Genero:Masculino  

firefox

 

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