为什么在 ActionScript 中添加粗体属性似乎会删除自动调整大小?
我需要在 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
autoSize
不是布尔值,而是字符串。请参阅文档。autoSize
is not a boolean, it's a string. See the documentation.你的环境是什么?如果您正在使用 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?