# AS3 - Font Loads but don't display... what could it be happening?

**URL:** <https://forum.kirupa.com/t/as3-font-loads-but-dont-display-what-could-it-be-happening/265285>\
**Category:** flash\
**Created:** [July 7, 2008, 1:33pm UTC](https://forum.kirupa.com/t/as3-font-loads-but-dont-display-what-could-it-be-happening/265285 "2008-07-07T13:33:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ad\_sign](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@ad\_sign](https://forum.kirupa.com/u/ad_sign)\
**Post date:** [July 7, 2008, 1:33pm UTC](https://forum.kirupa.com/t/as3-font-loads-but-dont-display-what-could-it-be-happening/265285/1 "2008-07-07T13:33:04Z")

</div>

I’m trying to load a custom font to use at runtime in AS3. The code seems to work but the font is not displayed properly. Could you point what I’m missing?

[LIST=1]  
[_]The SWF with the font item inside Library, which is exported with “GoodTimes” name, using “flash.text.Font” as the superclass.  
[_]FLA and its respective AS document class file. The code is quite simple, look:  
[/LIST]

```auto

package{

	import flash.display.Sprite;
	
	public class Test1 extends Sprite
	{
		import flash.display.Loader;
		import flash.net.URLRequest;
		import flash.system.LoaderContext;
		import flash.system.ApplicationDomain;
		import flash.events.Event;
		
		import flash.utils.getDefinitionByName;
		import flash.text.Font;
		import flash.text.TextField;
		import flash.text.TextFormat;
		
		static var GoodTimes:Class;
		
		function Test1():void
		{
			var loader:Loader = new Loader();
			var url:URLRequest = new URLRequest("temp/GoodTimes.swf");
			
			var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
			
			loader.contentLoaderInfo.addEventListener(Event.INIT, this.good);
			loader.load(url, context);
		}
		
		function good(e:Event):void
		{
			Test1.GoodTimes = getDefinitionByName("GoodTimes") as Class;
			
			trace(">:", Test1.GoodTimes);
			
			Font.registerFont(Test1.GoodTimes);
			
			this.startText();
		}
		
		function startText():void
		{
			trace("start drawing the TextField");
			
			var tf:TextField = new TextField();
			tf.width = 500; tf.height = 250;
			tf.x = tf.y = 50;
			
			tf.border = true;
		
			tf.defaultTextFormat = new TextFormat("GoodTimes", 12);
			trace(tf.defaultTextFormat.font);
		
			tf.text = "Sample text that should use GoodTimes, but shows itself in Default system font. What could be missing?";
		
			addChild(tf);
		}
	}
}

```
