External Text and External CSS

I’m trying to make a TextField instance, load external text, load external css, and apply the formatting. What should be very simple had become irritating.

I’m not sure what’s going on but the TextField is created, I’m getting confirmation that the text and css are loading correctly but the style is not being applied.

I’ve moved around some of the code to try and make sure that the css gets loaded *before *the style is applied – Unfortuantely, still a no-go.

Any suggestions?

//make a container
var sprContainer:Sprite = new Sprite();

//create a textfield
var tCal:TextField = new TextField();
tCal.text = "Test 
 Dog 
 Fish";


//put text field into container
sprContainer.addChild(tCal);

//add container to display list
this.addChild(sprContainer);

//Set textfield default size & position
tCal.border = true;
tCal.width = 294;
tCal.height = 107;
tCal.x = 135;
tCal.y = 253;
tCal.background = true;
tCal.multiline = true;
var textHolder:String;

//------------------------ External Text Loading ---------------------------------

//Load the external text
var txtLoader:URLLoader = new URLLoader();
txtLoader.addEventListener(Event.COMPLETE, onTextLoaded);
txtLoader.load(new URLRequest("tourschedule.txt"));


function onTextLoaded(event:Event):void{
    
    trace("text Loaded OK");
    
    tCal.htmlText = event.currentTarget.data as String;
    
    textHolder = event.currentTarget.data as String;
    //trace(textHolder);

}


//----------------------- CSS Loading --------------------------------------------

// create a new TextField.StyleSheet instance
var cssCalStyle:StyleSheet;

//load the external css
var cssLoader:URLLoader = new URLLoader();
cssLoader.addEventListener(Event.COMPLETE, cssStylesLoaded);
cssLoader.load(new URLRequest("calStyles.css"));


function cssStylesLoaded(event:Event):void {
    trace("CSS Loaded OK");
    
    cssCalStyle = new StyleSheet();
    cssCalStyle.parseCSS(event.currentTarget.data);
    
    tCal.styleSheet = cssCalStyle;
    
    
    
}