# Applying CSS to dynamic random text

**URL:** <https://forum.kirupa.com/t/applying-css-to-dynamic-random-text/288124>\
**Category:** flash\
**Created:** [May 11, 2009, 4:44pm UTC](https://forum.kirupa.com/t/applying-css-to-dynamic-random-text/288124 "2009-05-11T16:44:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganedenmichael](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@ganedenmichael](https://forum.kirupa.com/u/ganedenmichael)\
**Post date:** [May 11, 2009, 4:44pm UTC](https://forum.kirupa.com/t/applying-css-to-dynamic-random-text/288124/1 "2009-05-11T16:44:58Z")

</div>

Hi all,

I can’t seem to figure this out. I’m trying to apply a CSS stylesheet to a dynamic textbox that is populated with a random fact pulled from a .txt file. The text loads into the textbox but I can’t get the stylesheet to apply. I’d really appreciate any help. I’ve been working on this for days. Here’s the code:

var styles = new TextField.StyleSheet();  
styles.load(“[http://www.ganedentestsite.com/gbc30\_site/swf/fastfact.css](http://www.ganedentestsite.com/gbc30_site/swf/fastfact.css)”);  
styles.onLoad = function(loaded) {  
if(loaded){  
output\_mc.output.styleSheet = styles; [COLOR=Red]/_textbox name is “output” and it lives in movie clip “output\_mc” on the root level_/[/COLOR]  
}else{  
trace(“css didn’t load”); [COLOR=Red]/_this is just so I could see what’s going on_/[/COLOR]  
}

[COLOR=Red]/_Here’s where we start loading the random text from the .txt file. This part works fine._/[/COLOR]  
fastfact = new LoadVars();

```
    fastfact.onLoad=function(success){
        
        if(success){
            ranNum = Math.ceil(Math.random()*16);

            ranFact = this["quote"+ranNum];
            
            output_mc.output.htmlText = ranFact;
            }
            else{
    output_mc.output.htmlText="text failed";
    
            
}

```

}

```
    fastfact.load("http://www.ganedentestsite.com/gbc30_site/swf/fastfact.txt");

```

};

Thanks!
