Passing a font from one class to another
I loaded a font.swf (in Flash CS5)开发者_JAVA技巧 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...
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.
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);
精彩评论