Search Flex Components Free

Custom Search

January 23, 2008

Embedding fonts from a Flash SWF file into a Flex application

The following examples show how you can embed a font from a Flash SWF into a Flex application using @font-face in a <<:Style />> block, or using the [Embed] metadata.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx=""







private function init():void {

var appInfo:LoaderInfo = Application.application.loaderInfo;

/* Just grab the filename from the SWF URL. */

var fileName:String = (appInfo.url).split("/").pop();

/* Convert bytes to kilobytes. */

var kbTotal:String = (appInfo.bytesTotal / 1024).toFixed(2);

info.text = fileName + " (" + kbTotal + "kb)";






src: url('./fonts/fromFlash.swf');

fontFamily: "Myriad Web Pro";


.myriadWebProFromSWF {

fontFamily: "Myriad Web Pro";

fontSize: 24;



<mx:ApplicationControlBar dock="true">

<mx:Label id="info" />


<mx:Text styleName="myriadWebProFromSWF">

<mx:text>The quick brown fox jumped over the lazy dog.</mx:text>



Related Flex Tutorials