views:

28

answers:

1

i'm trying to implement the example found here:

http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d9a.html

I have successfully shared movieclips but the fonts don't seem to be available.

I am using AS3 for Flash - not Flex.

Thanks, Josh

A: 

just found the answer. when importing you need to register the font.

private function onComplete(evt:Event):void {

  var loaderInfo:LoaderInfo = evt.target as LoaderInfo;

  loaderInfo.removeEventListener(
    Event.COMPLETE,
    onComplete
  );

  var appDomain:ApplicationDomain = loaderInfo.applicationDomain;

  var thisIsMyFont:Class;

  try {

    thisIsMyFont = appDomain.getDefinition(
      "ThisIsMyFont"
    ) as Class;

  } catch(ex:Error) {

    throw new Error(
      "The font could not be found!"
    );

  }

  Font.registerFont(thisIsMyFont);

  trace(
    "Now there are " + Font.enumerateFonts().length + " fonts available"
  );

}
Josh