Revision: 58499
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 18, 2012 18:04 by ronniekleinfeldgmailcom
Initial Code
package ClientLoader { import flash.display.Loader; import flash.display.Sprite; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLRequest; import flash.text.Font; import flash.text.TextField; import flash.text.TextFormat; public class EmbededFonts extends Sprite { // embed a font from an external swf private var _loader:Loader; private var _fontLibrary:Class; public function EmbededFonts() { super(); _loader = new Loader(); var urlRequest:URLRequest = new URLRequest("assets/Fonts.swf"); _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _loader_onIoError); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _loader_onComplete); _loader.load(urlRequest); } protected function _loader_onIoError(event:IOErrorEvent):void { _loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, _loader_onIoError); trace("failed to load the .swf file"); } protected function _loader_onComplete(event:Event):void { _loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, _loader_onComplete); _fontLibrary = event.target.applicationDomain.getDefinition("BernardMTCondensedFont") as Class; // font family name Font.registerFont(_fontLibrary); DoPaint(); } private function DoPaint():void { var textFormat:TextFormat = new TextFormat(); textFormat.font = "Bernard MT Condensed"; // font name textFormat.bold = true; textFormat.letterSpacing = 10; var textField:TextField = new TextField(); textField.width = 300; textField.text = "99:99:99"; textField.textColor = 0x0000ff; textField.setTextFormat(textFormat); this.addChild(textField); } } }
Initial URL
Initial Description
embed a font from an external swf
Initial Title
embed a font from an external swf
Initial Tags
Initial Language
ActionScript 3