PDA

View Full Version : Applying CSS to dynamic random text



ganedenmichael
May 11th, 2009, 01:44 PM
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");
styles.onLoad = function(loaded) {
if(loaded){
output_mc.output.styleSheet = styles; /*textbox name is "output" and it lives in movie clip "output_mc" on the root level*/
}else{
trace("css didn't load"); /*this is just so I could see what's going on*/
}

/*Here's where we start loading the random text from the .txt file. This part works fine.*/
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!