[AS3]as3调用字体库文件类
[AS3]as3调用字体库文件类
调用字体库文件类
- var loader:Loader = new Loader();
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
- loader.load(new URLRequest(”fontlibrary.swf”));
- private function completeHandler(event:Event):void {
- var FontLibrary:Class = event.target.applicationDomain.getDefinition(”FontLibrary”) as Class;
- Font.registerFont(FontLibrary.BankGothicFont);
- var tf:TextField = new TextField();
- tf.defaultTextFormat = new TextFormat(”emBank Gothic”, 12, 0);
- tf.embedFonts = true;
- tf.rotation = 15; // to demonstrate the embed worked
- tf.text = “blah blah blahnblah blah blahnblah blah blah “;
- addChild(tf);
- }
- var loader:Loader=new Loader;
- loader.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHandler);
- loader.load(new URLRequest(”shared.swf”));
- function completeHandler(event:Event):void {
- var fontLibrary:Class=event.target.applicationDomain.getDefinition(”zhr_Font”) as Class;
- trace(fontLibrary);
- Font.registerFont(fontLibrary);
- test();
- }
- function test() {
- var _embeddedFonts:Array = new Array();
- _embeddedFonts = Font.enumerateFonts(false);
- trace(_embeddedFonts[0].fontName);
- //trace(_embeddedFonts.length);
- //var tx:TextField=new TextField();
- //tx.type=”input”;
- tx.embedFonts=true;
- //tx.defaultTextFormat=new TextFormat(”zhr_Font”,20,0xFF0000);
- var tf=new TextFormat(_embeddedFonts[0].fontName,20,0xFF0000);
- //tx.embedFonts = true;
- //tx.antiAliasType = AntiAliasType.ADVANCED;
- tx.text=”你好”;
- tx.setTextFormat(tf);
- addChild(tx);
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...