Monday 1 March 2010

dynamic fonts

1. Add a new font to the Library.
2. Give it a Name and export for ActionScript.
3. If you want a Bold or Italic font set it as so in the Style drop down.
4. Add the following code:

var myFont = new FontClassName();

var myTextFormat = new TextFormat()
myTextFormat.font = myFont.fontName

var myTextField = new TextField()
myTextField.embedFonts = true
myTextField.text = ""
myTextField.defaultTextFormat = myTextFormat
addChild(myTextField)

5. You can also set the text format like this:

myTextField.setTextFormat(myTextFormat)

No comments:

Post a Comment

Followers