package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.Event;
import flash.text.TextFieldAutoSize;
import flash.text.StyleSheet;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class CSSText extends Sprite {
public function CSSText( ) {
var loader:URLLoader = new URLLoader( );
loader.addEventListener(Event.COMPLETE, onLoadCSS);
var request:URLRequest = new URLRequest("styles.css");
loader.load(request);
}
private function onLoadCSS(event:Event):void {
var css:StyleSheet = new StyleSheet( );
css.parseCSS(URLLoader(event.target).data);
var field:TextField = new TextField( );
field.autoSize = TextFieldAutoSize.LEFT;
field.wordWrap = true;
field.width = 200;
addChild(field);
field.styleSheet = css;
field.htmlText = "Title
";
}
}
}