在AS3列表控件(flash.controls.List)中设置字体名称和大小
使用CS4,如何设置List控件的字体? 我试过这个:
var myFormat:TextFormat = new TextFormat();
myFormat.font = config.settings["list font name"];
myFormat.size = Number(config.settings["list font size"]);
list.setStyle("textFormat", myFormat);
没有骰子。
Using CS4, how do I set the font of a List control? I tried this:
var myFormat:TextFormat = new TextFormat();
myFormat.font = config.settings["list font name"];
myFormat.size = Number(config.settings["list font size"]);
list.setStyle("textFormat", myFormat);
No dice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以按实例、类和全局设置样式。
对于可选择列表(List、ComboBox、TileList 等),您需要使用 setRendererStyle 而不是 setStyle,因为您正在为每个单元格渲染器/项目设置样式,而不是列表本身,如果这有意义的话:
您也可以使用 StyleManager 来使用全局样式。
确保先嵌入您的字体,然后尝试
You can set styles by instance, class and globally.
For selectable lists(List,ComboBox,TileList,etc.), you need to use setRendererStyle instead of setStyle, because you're setting styles for each cell renderer/item, not the list itself, if that makes sense:
Also you can use global styles using StyleManager.
Make sure your fonts is embedded first, then try
遗憾的是,这花了我很长时间才弄清楚:
http://help.adobe.com/en_US/ AS3LCR/Flash_10.0/fl/controls/SelectableList.html#setRendererStyle()
This took me a long time to figure out, sadly:
http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/controls/SelectableList.html#setRendererStyle()
看来上面的答案相当旧,它们不再对我有用......
威尔·梅维斯提供的链接也不再打开。
无论如何,我找到了一种对我有用的方法(在 Flash CS6 上):
(如上所述,不要忘记嵌入您的字体)
It seems the answers above are rather old, and they no longer worked for me...
The link Will Mavis provided doesn't open anymore either.
Anyway, I found a way that worked for me (on Flash CS6):
(and as written above, don't forget to embed your font)