/ Published in: ActionScript 3
                    
                                        
Here is an intermediate example of how to load an external .txt file and apply an external .css
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/***************************************
Initialize Variables
***************************************/
var tf:TextField = new TextField();
tf.width = stage.stageWidth;
tf.height = stage.stageHeight;
addChild(tf);
var wordList:Array = new Array();
var textLoader:URLLoader = new URLLoader();
textLoader.addEventListener(Event.COMPLETE, textLoaded);
var cssLoader:URLLoader = new URLLoader();
var css:StyleSheet = new StyleSheet();
/***************************************
Parse Text + Apply External CSS
***************************************/
function cssLoaded(e:Event):void{
css.parseCSS(e.target.data);
tf.styleSheet = css;
for(var i:int = 0; i < wordList.length; i++){
tf.htmlText += "<h4>" + wordList[i] + "</h4>";
}
}
function textLoaded(e:Event):void{
wordList = e.target.data.split("\n");
cssLoader.load(new URLRequest("http://www.channelone.com/css/flash_block.css"));
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
}
textLoader.load(new URLRequest("http://www.channelone.com/fun/swf_band_name_txt.txt"));
Comments
 Subscribe to comments
                    Subscribe to comments
                
                