RSS
email
13

Embedding Font in Flash CS3(using AS3)



Here is the way to embed fonts in AS3.0, and the code explanation follows

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);


Code Explanation:

Importing all the necessary classes..
import flash.text.*;

Creating new instance of the font from library..
var font:Font1=new Font1();
Here Font1 is the Linkage name given in the library



Creating TextFormat
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24

Note:
font is the instance name of Linkage name

Creating text field and applying the TextFormat created above
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false

Adding the TextField to the DisplayList
addChild(txt);
Read more
 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.