# 2 in 1

**URL:** <https://forum.kirupa.com/t/2-in-1/186430>\
**Category:** flash\
**Created:** [April 21, 2006, 5:18am UTC](https://forum.kirupa.com/t/2-in-1/186430 "2006-04-21T05:18:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gdmt](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@gdmt](https://forum.kirupa.com/u/gdmt)\
**Post date:** [April 21, 2006, 5:18am UTC](https://forum.kirupa.com/t/2-in-1/186430/1 "2006-04-21T05:18:30Z")

</div>

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

thanx ni advance  
cheers!

(yes, my engish isn’t good ☹ )

---

<div class="post-metadata">

**Author:** ![B\_L\_U\_E](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@B\_L\_U\_E](https://forum.kirupa.com/u/B_L_U_E)\
**Post date:** [April 21, 2006, 4:51pm UTC](https://forum.kirupa.com/t/2-in-1/186430/2 "2006-04-21T16:51:56Z")

</div>

I believe you can use the same method for LoadVars  
[AS]myVars.onLoad = function(success) {  
if (success) {  
trace(“ok”);  
} else {  
trace(“error”);  
}  
}  
[/AS]

---

<div class="post-metadata">

**Author:** ![gdmt](https://avatars.discourse-cdn.com/v4/letter/g/b3f665/32.png) [@gdmt](https://forum.kirupa.com/u/gdmt)\
**Post date:** [April 22, 2006, 2:31am UTC](https://forum.kirupa.com/t/2-in-1/186430/3 "2006-04-22T02:31:12Z")

</div>

well, now i got this code:

// 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

thanks!
