1
votes

I have a parent swf with fonts embedded in the library, which have export for actionscript set and a class name assigned. The patent swf loads a number of child swfs to which I'm trying to pass a textformat object using a desired font from the parents library. How can this be achieved. I have tried Font.registerFont(font class) and created a new instance of the font before setting the textformat, but this only works on machines with the font installed.

In the child swf, the textfield text is set, then the textfomat applied with setTextFormat();

Any pointers greatly appreciated

2

2 Answers

0
votes

Have you tried something like this?

import flash.text.*;
var font:Font1=new Font1();
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false
addChild(txt);

The code is from http://sara-intop.blogspot.com/2007/10/embedding-font-in-flash-cs3using-as3.html

Also you can find useful this: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts.html

and this: http://learnola.com/2008/11/05/flash-tutorial-embed-fonts-in-actionscript-3/

0
votes

So, I figured it out. I had to use the array returned by Font.enumerateFonts and declare a new Font class, then create a Textfomat object within the child swf and apply it to the textfield.