# Preload txt/css, how to?

**URL:** <https://forum.kirupa.com/t/preload-txt-css-how-to/202487>\
**Category:** Uncategorized\
**Created:** [October 2, 2006, 1:56am UTC](https://forum.kirupa.com/t/preload-txt-css-how-to/202487 "2006-10-02T01:56:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wrs\_2](https://avatars.discourse-cdn.com/v4/letter/w/82dd89/32.png) [@wrs\_2](https://forum.kirupa.com/u/wrs_2)\
**Post date:** [October 2, 2006, 1:56am UTC](https://forum.kirupa.com/t/preload-txt-css-how-to/202487/1 "2006-10-02T01:56:42Z")

</div>

i have this code that loads css formated text from a .txt file, the problem is that i get “undefined” msg when i upload it, i’m guessing this is because the text or css is not preloaded, so how do preload this, here’s my text:

// 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 = “./xml/welcome.txt”;  
var css\_url = “./css/styles.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.  
styles\_txt.styleSheet = styles;  
styles\_txt.text = storyText;

}  
};
