Chapter 17 Example 16 actionscript.. forked:0favorite:0lines:33license : MIT License modified : 2010-01-27 13:59:45 Embed Tweet package { import flash.display.*; import flash.events.Event; import flash.net.URLRequest; import flash.system.*; import flash.text.*; public class ch17ex16 extends Sprite { protected const URL:String = "http://actionscriptbible.com/files/inconsolata.swf"; protected const CLASS_NAME:String = "com.actionscriptbible.assets.Inconsolata"; protected var loader:Loader; public function ch17ex16() { loader = new Loader(); loader.load(new URLRequest(URL), new LoaderContext( true, null, SecurityDomain.currentDomain)); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete); } protected function onLoadComplete(event:Event):void { var domain:ApplicationDomain = loader.contentLoaderInfo.applicationDomain; var fontClass:Class = domain.getDefinition(CLASS_NAME) as Class; Font.registerFont(fontClass); var tf:TextField = new TextField(); addChild(tf); tf.defaultTextFormat = new TextFormat("Inconsolata", 64); tf.antiAliasType = AntiAliasType.ADVANCED tf.width = stage.stageWidth; tf.height = stage.stageHeight; tf.multiline = tf.wordWrap = true; tf.embedFonts = true; tf.text = "Hello world"; } } } Code Fullscreen Preview Fullscreen as3bible dynamic font loading text textfield String Sprite