Tuesday, July 17, 2007

Sharing Fonts in ActionScript 3.0

http://www.communitymx.com/content/article.cfm?cid=67A61
import flash.display.Loader;

import
flash.display.LoaderInfo;
import
flash.net.URLRequest;

import
flash.events.Event;

var
fontLoader:Loader = new Loader();

var
fontLoaderInfo:LoaderInfo = fontLoader.contentLoaderInfo;

fontLoaderInfo.addEventListener(Event.COMPLETE, onFontLoaded);

fontLoader.load(new URLRequest("Verdana.swf"));

function
onFontLoaded (e:Event):void {

var
info:LoaderInfo = e.currentTarget as LoaderInfo;
var
loader:Loader = info.content as Loader;

var
embeddedFonts:Array = Font.enumerateFonts(false);
for
(var i:Number = 0; i < embeddedFonts.length; i++){

var
item:Font = embeddedFonts[i];
trace
("[" + i + "] name:" + item.fontName + ", style: " + item.fontStyle + ", type: " + item.fontType);
}
}

No comments: