7 Replies Latest reply on Jul 14, 2011 11:07 PM by Flex harUI

    Font loading error from application domain

    hyunil227

      Hi all,

       

      I am having trouble loading fonts from an external swf file. Any help would be very much appreciated.


      Here's the code:

       

      var AVAILABLE_FONTS:Array = ["Arial", "Impact"];

       

      var loader:Loader = new Loader();
      loader.contentLoaderInfo.
      loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fontLoadCompleteHandler);
      loader.load(new URLRequest("fonts.swf"));

       

      function fontLoadCompleteHandler(e:Event):void
      {
                   for (var i:uint = 0; i < AVAILABLE_FONTS.length; i++)
                   {
                       debug("Embedding Font: " + AVAILABLE_FONTS[i], Grim.NAME);
                       var FontLib:Class = (e.target as LoaderInfo).applicationDomain.getDefinition(AVAILABLE_FONTS[i]) as Class;
                       var font:Font = new FontLib() as Font;
                      
                       Font.registerFont();
                   }
                  
                   var fonts:Array = Font.enumerateFonts(false);
                   trace(fonts);
                  
                   dispatchEvent(new Event(INITIALIZED));
      }

       

      I get all the font classes correctly, but since they're in different application domain, I get this error:

       

      ArgumentError: Error #1508: The value specified for argument font is invalid.

       

      Any help?

       

      Thanks!