简体   繁体   English

从父级到子级swf嵌入as3字体

[英]as3 font embedding from parent to child swf

I have a parent swf with fonts embedded in the library, which have export for actionscript set and a class name assigned. 我有一个在库中嵌入字体的父swf文件,该字体已导出了actionscript集并分配了一个类名。 The patent swf loads a number of child swfs to which I'm trying to pass a textformat object using a desired font from the parents library. 专利SWF文件加载了许多子SWF文件,我正在尝试使用父库中所需的字体将textformat对象传递给该子SWF文件。 How can this be achieved. 如何做到这一点。 I have tried Font.registerFont(font class) and created a new instance of the font before setting the textformat, but this only works on machines with the font installed. 我已经尝试过Font.registerFont(font class)并在设置文本格式之前创建了字体的新实例,但这仅在安装了字体的机器上有效。

In the child swf, the textfield text is set, then the textfomat applied with setTextFormat(); 在子swf中,设置文本字段文本,然后使用setTextFormat();应用textfomat。

Any pointers greatly appreciated 任何指针非常感谢

Have you tried something like this? 你尝试过这样的事情吗?

import flash.text.*;
var font:Font1=new Font1();
var txt_fmt:TextFormat=new TextFormat();
txt_fmt.font=font.fontName;
txt_fmt.size=24
var txt:TextField=new TextField();
txt.autoSize=TextFieldAutoSize.LEFT;
txt.defaultTextFormat=txt_fmt;
txt.embedFonts=true
txt.text="sara"
txt.selectable=false
addChild(txt);

The code is from http://sara-intop.blogspot.com/2007/10/embedding-font-in-flash-cs3using-as3.html 该代码来自http://sara-intop.blogspot.com/2007/10/embedding-font-in-flash-cs3using-as3.html

Also you can find useful this: http://www.adobe.com/devnet/flash/quickstart/embedding_fonts.html 您也可以找到有用的方法: http : //www.adobe.com/devnet/flash/quickstart/embedding_fonts.html

and this: http://learnola.com/2008/11/05/flash-tutorial-embed-fonts-in-actionscript-3/ 和这个: http : //learnola.com/2008/11/05/flash-tutorial-embed-fonts-in-actionscript-3/

So, I figured it out. 所以,我想通了。 I had to use the array returned by Font.enumerateFonts and declare a new Font class, then create a Textfomat object within the child swf and apply it to the textfield. 我必须使用Font.enumerateFonts返回的数组,并声明一个新的Font类,然后在子swf中创建一个Textfomat对象,并将其应用于文本字段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM