嵌入字体在AS3 - 动态文本字段消失 [英] Embedding Fonts in AS3 - Dynamic Text Field disappears

查看:342
本文介绍了嵌入字体在AS3 - 动态文本字段消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是希望一个新的问题或只是我缺少明显的东西。请帮忙!我嵌入字体到我的AS3的应用程序。我在做由这本书的一切,它一半的作品。

This is hopefully a new problem or just me missing something obvious. Please help! I'm embedding a font into my AS3 application. I'm doing everything by-the-book and it half-works.

在我的主类,

    [Embed(source="Art/moolbor.ttf", fontFamily="MoolEmbed", 
        mimeType="application/x-font")]
    var MoolEmbed:Class;

再后来就在我的code:

Then later on in my code:

    var newFormat:TextFormat = new TextFormat();
    newFormat.font = "MoolEmbed";
    newFormat.size = 20;
    newFormat.color = 0xFCF374;

    year.autoSize = TextFieldAutoSize.LEFT;
    year.text = "Hello World";
    year.embedFonts = true;
    year.setTextFormat(newFormat);
    year.antiAliasType = "advanced";

这工作完全正常,并且文本显示粉墨登场。我可以旋转它,阿尔法适用于它,而且它很好地抗锯齿。问题是,文本域是动态的 - 后来在code:

This works perfectly fine, and the text shows up beautifully. I can rotate it, alphas apply to it, and it's nicely antialiased. The problem is that the textfield is dynamic - Later on in the code:

    year.text = "And a second hello world";

一旦这个code被触发,该文本框完全消失。我打开

As soon as this code is triggered, the textfield disappears completely. I turn on

    year.border = true;

和我可以看到文本框是仍然存在,但它的规模已经缩小到只有几个像素。心想也许是将AutoSize搞乱的东西了,

and I can see that the textfield is still there, but it's size has shrunk down to just a few pixels. Thinking perhaps it was the autoSize messing things up,

    //year.autoSize = ...;

相同的问题。想这可能是埋线,我注释掉该行:

Same problems. Thinking it might be embedding, I commented out the line:

    //year.embedFonts = true;

和文本域返回到工作状态,但(可以理解)失去它有能力做阿尔法和旋转。

And the textfield returns to working status, but (Understandably) loses it's ability to do alphas and rotations.

任何想法是怎么回事?

推荐答案

我写的可能原因,为什么这是行不通的长健谈的条目。但是,当我再看到你code我想我发现了错误。 更改该行:

I wrote a long talkative entry on possible reasons as why this would not work. But as I re-read you code I think i spotted the error. Change the row:

year.setTextFormat(newFormat);

要:

year.defaultTextFormat = newFormat;

这应该这样做!

这篇关于嵌入字体在AS3 - 动态文本字段消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆