I’m having a big problem but I read a tutorial for Flash MX that makes me think I know what the problem is but I don’t know how to fix it! (ha!) I have a site with a scrolling formatted text box. But – many times I’ll load the page and you can see the html tags with the text unformatted, but then you refresh and it seems fine, refresh again, and you see the tags, etc.
I was reading this tutorial: http://www.kirupa.com/developer/mx2004/css2.htm
and came across the part where it says “Before we apply the CSS file though, I make sure to tell Flash to ensure the CSS file loads first before displaying the text in the text field. Only after the CSS file loads do I tell Flash to transfer the data in format and the HTML text in quick to the text field named output.” and it seems to me that is what’s happening with my code (that I got from another tutorial) I know this is a on MX, but if anyone could take a look at my code and see how I could force the CSS to load before the text appears I think that would fix my problem.
Here is my loading external text code:
//--------------loading external text and display it---------
var cssUrl:URLRequest = new URLRequest(“default.css”);
var cssLoader:URLLoader = new URLLoader();
cssLoader.load(cssUrl);
cssLoader.addEventListener(Event.COMPLETE,cssLoaded);
function cssLoaded(event:Event):void {
var css:StyleSheet = new StyleSheet();
css.parseCSS(URLLoader(event.target).data);
text_field.styleSheet = css;
}
var textRequest:URLRequest = new URLRequest(“home.txt”);
var textLoader:URLLoader = new URLLoader();
textLoader.load(textRequest);
textLoader.addEventListener(Event.COMPLETE,fileLoaded);
function fileLoaded(event:Event):void {
text_field.text = event.target.data;
text_field.wordWrap = true;
}
and the opensource file with css and txt file is here if anyone wants to check it out: www.markasey.com/fla
Any ideas would be greatly appreciate. Thanks, Mark