为什么在 ActionScript 中添加粗体属性似乎会删除自动调整大小?

发布于 2024-09-13 14:20:14 字数 782 浏览 14 评论 0原文

我需要在 ActionScript 中将文本字段设置为自动调整大小和粗体。由于某种原因,当我应用粗体格式时, autosize=true 丢失了。据我所知,我正在按照正确的顺序做所有事情。对于正在发生的事情的任何想法都非常感谢。谢谢!

这是相关代码:

varcategoryMenu:MovieClip = _root.createEmptyMovieClip("categoryMenu", 1005);

var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;

for (var i:Number = 0; i<numCat; i++) {
    var menu:MovieClip = categoryMenu.attachMovie("menu", "menu"+i,i);
    menu._txt.txt.autoSize = true;
    menu._txt.txt.text = gallData.getMenuGall.name[i];
            //if i comment out the following line, the autosize works.
            //if i leave it in, the autosize is lost.  but i can't put this line
            //before the autosize or i lose the bold
    menu._txt.txt.setTextFormat(my_fmt);
     ...
     }

I have text fields that I need to set as both autosize and bold in ActionScript. For some reason, when I apply the bold formatting, the autosize=true is lost. From what I can tell, I am doing everything in the correct order. Any thoughts on what is going on are hugely appreciated. Thanks!

Here is the relevant code:

var categoryMenu:MovieClip = _root.createEmptyMovieClip("categoryMenu", 1005);

var my_fmt:TextFormat = new TextFormat();
my_fmt.bold = true;

for (var i:Number = 0; i<numCat; i++) {
    var menu:MovieClip = categoryMenu.attachMovie("menu", "menu"+i,i);
    menu._txt.txt.autoSize = true;
    menu._txt.txt.text = gallData.getMenuGall.name[i];
            //if i comment out the following line, the autosize works.
            //if i leave it in, the autosize is lost.  but i can't put this line
            //before the autosize or i lose the bold
    menu._txt.txt.setTextFormat(my_fmt);
     ...
     }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

所谓喜欢 2024-09-20 14:20:14

autoSize 不是布尔值,而是字符串。请参阅文档

autoSize is not a boolean, it's a string. See the documentation.

浮世清欢 2024-09-20 14:20:14

你的环境是什么?如果您正在使用 Flash CS?您的代码中定义的文本格式是否可能与 MovieClip 中的文本字段实例冲突?

what's your environment? If you're working with Flash CS? Is is possible that the text formatting defined in your code is conflicting with the textfield instance in your MovieClip?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文