Using embedded fonts with the DataGrid control in Flash CS3

by Peter deHaan on March 10, 2008

in DataGrid

The following example shows how you can use embedded fonts with a Flash CS3 DataGrid control in ActionScript 3.0.

Full code after the jump.

// ActionScript 3.0
/**
 * Requires:
 *   - a DataGrid control on the display list with an 
 *      instance name of "dataGrid".
 */
import fl.controls.dataGridClasses.DataGridColumn;
import fl.controls.dataGridClasses.HeaderRenderer;
import fl.data.DataProvider;
 
var f1:Font = new VerdanaEmbedded() as Font;
 
var headerTF:TextFormat = new TextFormat();
headerTF.bold = false;
headerTF.font = f1.fontName; // Verdana
headerTF.size = 16;
 
var rowTF:TextFormat = new TextFormat();
rowTF.bold = false;
rowTF.font = f1.fontName; // Verdana
rowTF.size = 9;
 
var fontArr:Array = Font.enumerateFonts(true);
fontArr.sortOn("fontName", Array.CASEINSENSITIVE);
 
var headRen:HeaderRenderer = new HeaderRenderer();
headRen.setStyle("embedFonts", true);
 
var fontNameCol:DataGridColumn = new DataGridColumn("fontName");
fontNameCol.headerText = "fontName:";
fontNameCol.headerRenderer = headRen;
 
dataGrid.setRendererStyle("embedFonts", true);
dataGrid.setRendererStyle("textFormat", rowTF);
dataGrid.setStyle("headerTextFormat", headerTF);
dataGrid.columns = [fontNameCol];
dataGrid.dataProvider = new DataProvider(fontArr);
dataGrid.rowCount = 10;

{ 0 comments… add one now }

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: