Formatting text with an externally loaded style sheet : URLRequest : Network Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Network » URLRequest »

 

Formatting text with an externally loaded style sheet


 

package {
  import flash.display.*;
  import flash.text.*;
  import flash.events.*;
  import flash.net.*;

  public class Main extends Sprite {
    public function Main(  ) {
      var urlLoader:URLLoader = new URLLoader(  );
      urlLoader.addEventListener(Event.COMPLETE, completeListener);
      urlLoader.load(new URLRequest("styles.css"));
    }

    private function completeListener (e:Event):void {
        var styleSheet:StyleSheet = new StyleSheet(  );
        styleSheet.parseCSS(e.target.data);
        var t:TextField = new TextField(  );
        t.width = 200;
        t.styleSheet = styleSheet;
        t.htmlText = "<p>ActionScript is fun!</p>";
    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Network
» URLRequest