Comunidad de diseño web y desarrollo en internet online

2 in 1

Citar            
MensajeEscrito el 21 Abr 2006 06:44 am
hola a todos!
bueno, tengo este codigo... y me gustaria personaizaro mas porke muestra un mensaje solo si falla a carga del .css... y el .htm? como puedo hacerlo?
y seria mejor si aguien sabe como hacer un link en el mensaje de carga fallida, para ke vuelva a cargar estos archivos o actualice la pagina...

// Create a new style sheet and LoadVars object
var myVars:LoadVars = new LoadVars();
var styles = new TextField.StyleSheet();
// Location of CSS and text files to load
var txt_url = "news.htm";
var css_url = "news.css";
// Load text to display and define onLoad handler
myVars.load(txt_url);
myVars.onData = function(content) {
storyText = content;
};
// Load CSS file and define onLoad handler:
styles.load(css_url);
styles.onLoad = function(ok) {
if (ok) {
// If the style sheet loaded without error,
// then assign it to the text object,
// and assign the HTML text to the text field.
svnews.styleSheet = styles;
svnews.text = storyText;
} else {
svnews.htmlText = "<br><br><br><br><br><br><br><br><p align='center'><font color='#FF0000'>¡ERROR!<BR>CARGA DE DATOS FALLIDA</font></p>";
}
}

espero ke puedan ayudarme, no parece dificil...

y... otra cosa... hay algun cdigo para hacer ke un mc este arriba de todos los demas? porke cargo un swf dentro de otro, y kiero ke un mc dentro de archivo caragado, este arriba de todos los demas elementos de swf principal...

gracias por adelantado...
saludos!

Por gdmt

7 de clabLevel



 

msie
Citar            
MensajeEscrito el 21 Abr 2006 07:31 am
Hola puedes comenzar definiendo una nueva instancia de LoadVars, luego con un onLoad miras si lo ha cargado, si no, pues haces lo mismo que estan haciendo con el CSS...

Por otro lado para que siempre pueda estar arriba, podrias usar un swapDepths()

Direcciones que puedes ver:
http://www.cristalab.com/tutoriales
http://www.cristalab.com/tutoriales/6/tutorial-de-loadvars-en-flash-mx-2004
http://www.flashla.com/refAS/LoadVars.php
http://www.after-hours.org/foro/viewtopic.php?t=6199

Salu2

Por eporroa

664 de clabLevel



Genero:Masculino  

Lima - Peru

firefox
Citar            
MensajeEscrito el 21 Abr 2006 04:43 pm
muchas gracias por tu respuesta Xroa©!
voy a probar lo ke me recomendaste!

Por gdmt

7 de clabLevel



 

msie
Citar            
MensajeEscrito el 21 Abr 2006 05:52 pm
bueno, probe lo de swapDepths() y paso lo sig.:
mi animacion es de 60 frames, y el mc ke le asigne swapDepths() llega solo hasta el 2do frame ¿por que lo sigue mostrando, por ej.: en el frame 30? porke si le saco el swapDepths(), keda oculto a partir del frame 3.
se entiende lo ke kiero decir?

Por gdmt

7 de clabLevel



 

msie
Citar            
MensajeEscrito el 22 Abr 2006 03:30 am
bueno, consegui este codigo...

// Create a new style sheet and LoadVars object
var myVars:LoadVars = new LoadVars();
var styles = new TextField.StyleSheet();
// Location of CSS and text files to load
var txt_url = "news.htm";
var css_url = "news.css";

// Load css and text to display
function cargar(){
myVars.load(txt_url);
styles.load(css_url);
}
cargar();

// Define onLoad handlers:
myVars.onData = function(content) {
if(content != undefined){
storyText = content;
} else {
storyText = "<br><br><br><br><br><br><br><br><p align='center'><font color='#FF0000'>¡ERROR!<BR>CARGA DE DATOS FALLIDA</font><br><a href=\"asfunction:cargar\">Recargar</a></p>";
}
};
styles.onLoad = function(ok) {
if (ok) {
// If the style sheet loaded without error,
// then assign it to the text object,
svnews.styleSheet = styles;
}
// assign the HTML text to the text field.
svnews.text = storyText;
}
y andubo bien, pero paso lo sig.:
1.- cambio el nombre de archivo solo del .htm = se muestra el mensaje para volver a cargar.
2.- cambio el nombre de archivo solo del .css = muestra un mensaje no declarado por mi.. simplemente pone "undefined"
3.- cambio el nombre de ambos archivos = muestra "<br><br><br><br><br><br><br><br><p align='center'><font color='#FF0000'>¡ERROR!<br>CARGA DE DATOS FALLIDA<br><br><a href=\"asfunction:cargar\">RECARGAR</a></font></p>" (asi como esta, sin formatearlo)

intente resolverlo pero no pude, alguna sugerencia?

creo ke lo mejor seria hacer algo asi:
cargar news.htm
si cargo el news.htm
cargar news.css
sino
mostar mensaje de carga fallida (sin formato css, todavia no se cargo news.css)
si cargo news.css
mostrar el texto en textfield
sino
mostar mensaje de carga fallida

el problema es ke no pude decir esto en lenguaje actionscript :(

gracias...

Por gdmt

7 de clabLevel



 

msie

 

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