I\'m using Flash CS4.\r\n\r\n1.First thing you need to do is turn your font into a class that can be loaded.\r\n When you create your class pay special attention to the fontName you give it. You will need that later. NOTE: only TrueType fonts will work.\r\n2.Now that your font is a class its accessible to the rest of your code. The difference is, you access it by the fontName you assigned it earlier.\r\n3. WARNING: In-order for your font to show up on the stage, your font has to be embedded in the textField:\r\n4. WARNING: When setting the TextFormat, you MUST use defaultTextFormat. setTextFormat() will not work.\r\n5. SIDE NOTE: If your using an AssetMangement class. (ie. a once stop shop class that loads everything). You provide access to this class and its loaded fonts by creating a variable that is equal to the font in the AssetManagement class. See the example below.
//This line can be in the timeline or if your using a class, within the class, Not within a function. [Embed(source='/assets/fonts/NeoSans.ttf', fontName="TheCrazyMan", mimeType="application/x-font-truetype")] public static var FONT_NEOSANS:Class; //<------------Variable must be static in-order for this to work. //////////////////////////////////////////////////////TextFormat Creation var format:TextFormat = new TextFormat(); format.font = "TheCrazyMan"; format.color = "0xB10101"; format.size = 14; //////////////////////////////////////////////////////Dynamic Text Field var tf:TextField = new TextField(); tf.embedFonts = true; //<----------------------------embedFonts must be true; tf.selectable = false; tf.x = 8; tf.y = 20; tf.defaultTextFormat = format; //<-------------------Must be defaultTextFormat; tf.text = "A new font"; addChild(tf); //////////////////////////////////////////////////////Text Field already on stage titled testText1 testText1.defaultTextFormat = format; testText1.text = "A new font"; testText2.embedFonts = true; //<--------------------embedFonts must be true; testText2.defaultTextFormat = format2; //<-----------Must be defaultTextFormat; testText2.text = "A new font"; //////////////////////////////////////////////////////If Using AssetManagement Solution import AssetManager; public class Main extends MovieClip { var FT:Class = AssetManager.FONT_NEOSANS; //<-------Gives access to font in AssetManager class. public function Main() { // Continue with TextFormat and Text Field code above. } }
You need to login to post a comment.
