views:

14

answers:

2

I loaded a font.swf (in Flash CS5) and it works in the class I loaded the font into, but if I want to pass it to another class, how do I do that?

I tried passing it as a TextFormat instance (with the format.font = my_loaded_font) but that doesn't appear to work...

+1  A: 

Once a font is embedded, you refer to it by its family name as a String. It need not be passed from class to class.

Tegeril
So if I want a textfield with my font, I can just write: new TextFormat(“My-Font-Name") anywhere in my project and it will work?
redconservatory
Yeah, as long as the font name matches exactly with what is specificed in the font metadata and you've embedded it anywhere else in the compiled SWF.
Tegeril
A: 

Fonts are global once loaded; you access them by their name in the global font list. See here:

http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/text/Font.html#enumerateFonts()

import flash.text.Font;

var allFonts:Array = Font.enumerateFonts(true);
Casey