Swf assets, loading fonts in Actionscript using FlashDevelop (AS3 project)

I know this has been posted and discussed over and over again, but whatever solution i use (and there are generally two types), none work me. Even worse, all those examples were from as early as 2007 !

Now to the problem. I use FlashDevelop 4.0.0 RC1 and Flex SDK 4.5.1 (downloaded during FD install).

This is a font asset swf that holds my font to be loaded later in separate swf project in FD4. Example 1:


package
 {
 import flash.display.Sprite;

 public class ExtFontLib extends Sprite
  {
  [Embed(source="../lib/6809CHAR.TTF", fontName='6809 Chargen', mimeType="application/x-font")]
  public static var MyFont : Class;
  }
 }

Other method is slightly different. Example 2


package
 {
 import flash.text.Font; 

 [Embed(systemFont='Bank Gothic', fontName='emBank Gothic', mimeType='application/x-font')] 
 public class BankGothicNormalFont extends Font {}
 }

And now test app:


package
 {
 import flash.display.Loader;
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.net.URLRequest;
 import flash.text.*;
 import mx.logging.*;


 public class TestFont extends Sprite
  {

  public function TestFont () : void 
   {
   if (stage) init ();
   else addEventListener (Event.ADDED_TO_STAGE, init);
   }
  private function init (e : Event = null) : void 
   {
   removeEventListener (Event.ADDED_TO_STAGE, init);
   BeginProgram (); // entry point
   }
  private function BeginProgram () : void
   {
   loadFont ("http://127.0.0.1/ExtFontLib.swf");
   }
  private function loadFont (url : String) : void
   {
   var loader : Loader = new Loader ();
   loader.contentLoaderInfo.addEventListener (Event.COMPLETE, completeHandler);
   loader.load (new URLRequest (url));
   }
  private function completeHandler (event : Event) : void
   {
   var LoadedFontLibrary : Class = event.target.applicationDomain.getDefinition  ("ExtFontLib") as Class;
   Font.registerFont (LoadedFontLibrary.MyFont);  //PROBLEM SPOT
   test ();
   }
  public function test () : void
   {
   var tf : TextField = new TextField ();
   tf.embedFonts = true;
   tf.antiAliasType = AntiAliasType.ADVANCED;
   tf.autoSize = TextFieldAutoSize.LEFT;
   tf.border = true;
   tf.borderColor = 0xff7777;
   tf.textColor = 0x000000;
   tf.x = 100;
   tf.y = 100;
   tf.text = "testing
1234567890
anotherline";
   tf.setTextFormat (new TextFormat ("6809 Chargen", 16, 0));
   tf.rotation = 15;
   stage.addChild (tf);
   }
  }
 }

I used source from example 1 and tried loading it in test app and got error


[Fault] exception, information=ArgumentError: Error #1508: The value specified for argument font is invalid.

It fails at line with “Font.registerFont (LoadedFontLibrary.MyFont)”.

If i try with example 2, i am loading with above line modified to “Font.registerFont (LoadedFontLibrary)” and get error


[Fault] exception, information=TypeError: Error #2023: Class ExtFontLib$ must inherit from Sprite to link to the root.

So in both cases it fails. Any ideas ?