# External txt with external css

**URL:** <https://forum.kirupa.com/t/external-txt-with-external-css/110256>\
**Category:** Uncategorized\
**Created:** [May 13, 2004, 6:50pm UTC](https://forum.kirupa.com/t/external-txt-with-external-css/110256 "2004-05-13T18:50:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Webfoley](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@Webfoley](https://forum.kirupa.com/u/Webfoley)\
**Post date:** [May 13, 2004, 6:50pm UTC](https://forum.kirupa.com/t/external-txt-with-external-css/110256/1 "2004-05-13T18:50:44Z")

</div>

I recently followed the steps in tutorials [color=#003366]\*\*Using \*\*CSS Styles in Flash MX 2004 [color=#000000]and [/color] **Applying** [/color][color=#003366] CSS to Externally Loaded Text. Although I attemped a couple of times I could not get anything to work… the text or the css. I don’t even generate the text that says I cannot load the CSS file. Any suggestions would be appreciated.

Thanks,  
-Webfoley (the code I used is below)[/color]

1. I created a dynamic textbox with render HTML on and instance name ‘textbox’.
2. The external text file is located in folder ‘txt’ and is called mytext.txt. It begins with thetext=
3. For my trial I used the Kirupa CSS called flash.css and referenced the \<p class=‘four’\> in the mytext.txt content.
4. I use a movieclip with the top layer action on the first frame and the textbox used on the layer below. The action reads:

var format = new TextField.StyleSheet();  
var path = “[http://www.kirupa.com/developer/mx2004/code/flash.css](http://www.kirupa.com/developer/mx2004/code/flash.css)”;  
format.load(path);  
format.onLoad = function(loaded) {  
if (loaded) {  
textbox.styleSheet = format;  
myLoadVar = new LoadVars ();  
myLoadVar.load(“txt/mytext.txt”)  
myLoadVar.onLoad = function (success){  
if (success == true) {  
textbox.variable = “thetext”  
textbox.htmlText=myLoadVar.thetext;  
}  
}  
} else {  
output.text = “Error loading CSS file!”;  
}  
};
