Using embedded fonts with the Button control in Flash CS3

by Peter deHaan on March 11, 2008

in Button

The following example shows how you can use embedded fonts (normal weight and bold weight) with a Flash CS3 Button control in ActionScript 3.0.

Full code after the jump.

/**
 * Requires:
 *   - three Button controls on the display list with 
 *      instance names of "button1", "button2", and 
 *      "button3".
 *   - an embedded font in your library with a linkage
 *      identifier of "EmbeddedVerdana" and a normal 
 *      font weight.
 *   - an embedded font in your library with a linkage
 *      identifier of "EmbeddedVerdanaBold" and a bold
 *      font weight.
 */
const STR:String = "The quick brown fox";
 
var f2:Font = new EmbeddedVerdana() as Font;
var f3:Font = new EmbeddedVerdanaBold() as Font;
 
var tf1:TextFormat = new TextFormat();
tf1.font = "Verdana";
 
var tf2:TextFormat = new TextFormat();
tf2.font = f2.fontName; // Verdana
 
var tf3:TextFormat = new TextFormat();
tf3.font = f3.fontName; // Verdana
tf3.bold = true;
 
button1.label = STR;
button1.setStyle("textFormat", tf1);
 
button2.label = STR;
button2.setStyle("embedFonts", true);
button2.setStyle("textFormat", tf2);
 
button3.label = STR;
button3.setStyle("embedFonts", true);
button3.setStyle("textFormat", tf3);

{ 1 comment… read it below or add one }

1 venkatswamt 08.28.08 at 5:58 am

iwant freeactin script example to learn

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

Previous post:

Next post: