DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Kalatravas has posted 29 posts at DZone. View Full User Profile

Loading External Text-file Into CS3 TextArea And Styling Through CSS

09.14.2010
| 3414 views |
  • submit to reddit
        // Actualy the customTextArea is extending the Adobe's TextArea component . The class can be downloaded from here >>> http://www.gskinner.com/blog/archives/2008/03/adding_css_supp.html .For more info visit 

http://tournasdimitrios1.wordpress.com/2010/09/13/manipulating-the-textarea-component-in-flash-cs3/#more-1898

var style:StyleSheet = new StyleSheet();
style.setStyle(".heading", {fontWeight:"bold", color:"#FF0000", fontSize:22});
style.setStyle("body", {fontStyle:"italic" ,fontSize:18 , color:"#0000ff"});
style.setStyle(".customStyle" , {fontStyle:"italic" , fontSize:30 ,color:"#00ff00"});
customTextArea.setStyle("styleSheet", style);

var req:URLRequest = new URLRequest("externalText.txt");
var textLoader:URLLoader = new URLLoader();
textLoader.addEventListener(Event.COMPLETE , textLoaded);
textLoader.load(req);

function textLoaded(evt:Event):void {
    textLoader.removeEventListener(Event.COMPLETE , textLoaded);	
	
	customTextArea.htmlText = evt.target.data;
	}