hi everybody!
well, i got this code… and i’d like to personalize it more… 'cause it shows a message only if .css file fails… what about the .htm file, how can i do it?
it could be better if someone knows the way the make a link in the “load failed message” to load again those files… or just refresh de page…
// 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>”;
}
}
hope u can help me, it doesn’t seem difficult
and… there is some code to make a movie clip stay over the other elements? like above in layers? 'cause i load a swf in other swf… and i need a mc stay over the elements in the main swf
I believe you can use the same method for LoadVars
[AS]myVars.onLoad = function(success) {
if (success) {
trace(“ok”);
} else {
trace(“error”);
}
}
[/AS]
// 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;
}
it’s better than the other, but…
1.- changing the name of .htm file (like failed load) = shows the message with link to reload.
2.- changing the name of .css file (like failed load) = shows just "undefined"
3.- changing the name of both files = shows “<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>” (no format)
try to solve it but I could not, any suggestion?
i mean, i want this:
load news.htm
if news.htm loaded
load news.css
else
show load failed message (no css style, not loaded yet)
if news.css loaded
show text ni textfield with styles
else
show load failed message (no css style, not loaded yet)
the problem is that i can’t say it in actionscript language