Hi,
I am trying to defeat my psychological block with dynamically loaded fonts in AS3, and I have an annoying problem. I am creating a clock with a textfield and I am loading fonts from a SWF library: the available classes/linkages are “Arial”, “ArialBold”, “MyriadPro”, “MyriadProBold” and “Verdana”.
This is the line where I get the class from the SWF, and it extracts the class correctly
clock = new Clock( { fontClass: assetsLoader.getFontClass("skin", "Arial") } );
The constructor…
public function Clock(_clockProperties : Object) {
Font.registerFont(_clockProperties.fontClass);
clockFormat = new TextFormat();
clockFormat.size = 20;
clockFormat.color = 0xFFFFFF;
clockFormat.align = TextFormatAlign.CENTER;
clockFormat.font = getQualifiedClassName(_clockProperties.fontClass);
trace("FONT CLASS = " + getQualifiedClassName(_clockProperties.fontClass));
clockTextField.multiline = false;
clockTextField.wordWrap = false;
clockTextField.selectable = false;
clockTextField.embedFonts = true;
clockTextField.antiAliasType = AntiAliasType.ADVANCED;
clockTextField.type = TextFieldType.DYNAMIC;
clockTextField.width = 200;
clockTextField.height = 40;
clockTextField.defaultTextFormat = clockFormat;
this.addChild(clockTextField);
setActualTime(clockProperties.withSeconds);
}
...
Now, if I use “Arial” and “Verdana” this works correctly, I see the clock, but if I use “ArialBold”, “MyriadPro” or “MyriadProBold” I can’t see anything, just the output “FONT CLASS = MyriadPro” that tells me that the font has been loaded.
Why do I see 2 fonts on 5?!
Am I registering the fonts in the wrong domain? I am loading the SWF with Greensock SWFLoader, specifying the loader context “new LoaderContext(false, ApplicationDomain.currentDomain)”