Posts Tagged Fonts
I just thought I’d make a quick post about how to use embedded fonts in Flash CS3 using ActionScript 3 because I had to do that last week and I did really know how to do it. Well it starts just as you did in Flash 8, you right click in the library and you choose New Font… Then choose the font you want to embed and click Ok. Now you’ll have to right click on the new font in the library and choose linkage. In the pop window, click export for ActionScript and give it a class name. Once that is done you can use that font in any textfields you create with ActionScript.
Here is code showing you how to do it:
1 2 3 4 5 6 7 8 9
var helve:Font = new Helve(); buttonLabel = new TextField(); txtFormat = new TextFormat(); txtFormat.font = helve.fontName; txtFormat.color = 0x000000; txtFormat.size = 14; buttonLabel.embedFonts = true; buttonLabel.text = "place label text here"; buttonLabel.setTextFormat(txtFormat);
My font class name in the library was Helve. I use the TextFormat object to set the font for the textfield, it’s that easy.