简体   繁体   English

如何使用as3代码为特定的输入文本字段嵌入字体

[英]how to embed a font for specific input text field using as3 codes

how to embed a font for text1 which is an input text field using as3 codes only 如何为仅使用as3代码的输入文本字段text1嵌入字体

also in file text2 which is a dynamic text field how to get whole which I typed in text1 同样在文件text2中,这是一个动态文本字段,如何获取我在text1中键入的全部内容

I appreciate everyone who would try to help me 感谢所有愿意帮助我的人

this is my code 这是我的代码

import flash.events.KeyboardEvent;


stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);



function reportKeyDown(event:KeyboardEvent):void
{
    stage.focus = text1;
 text2.text =(" Key Pressed:   " + String.fromCharCode(event.charCode) );

}
import flash.text.TextFormat;

var myForm:TextFormat = new TextFormat();
myForm.font = new ArialRegular().fontName;
text1.setTextFormat(myForm);

"ArialRegular" is the declared class name of the embedded font. “ ArialRegular”是嵌入字体的声明的类名称。 To embed a font, select desired font from Family dropdown. 要嵌入字体,请从“族”下拉列表中选择所需的字体。 Click the "Embed..." button, a dialog will appear. 单击“嵌入...”按钮,将出现一个对话框。 Give it a unique descriptive name and tic the checkboxes for the desired character ranges then select the "Actionscript" tab near the top of the dialog and then check the box next to "Export for Actionscript" under Linkage. 为它指定一个唯一的描述性名称,并选中所需字符范围的复选框,然后选择对话框顶部附近的“ Actionscript”选项卡,然后选中“链接”下“ Export for Actionscript”旁边的框。 The name you gave it on the previous tab will become the Class name. 您在上一个选项卡上给它的名称将成为类名称。 (ArialRegular for example) (例如,ArialRegular)

As for duplicating the text from one to another, I haven't tested this and I'm kinda sleepy but should work: 至于将文本从一个复制到另一个,我还没有测试过,我有点困,但是应该可以工作:

text1.addEventListener(KeyboardEvent.KEY_UP, ditto);

function ditto(e:KeyboardEvent):void {
    text2.text = ("Key Pressed: " + e.target.text);
}

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

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