【发布时间】:2012-02-02 00:56:15
【问题描述】:
是否可以使用 Actionscript 3.0 在一个文本字段中设置两种文本颜色?
例如:我怎样才能让第一个字符串变成黑色,第二个字符串变成红色?
这是我使用单一颜色时的代码:
public function logs(txt)
{
if (txt == '')
{
textLog.text = "Let's Open up our treasure boxes !!!";
}
else
{
textLog.text = '' + txt + '';
}
textLog.x = 38.60;
textLog.y = 60.45;
textLog.width = 354.50;
textLog.height = 31.35;
textLog.selectable = false;
textLog.border = false;
var format:TextFormat = new TextFormat();
var myFont:Font = new Font1();
format.color = 0x000000;
format.font = myFont.fontName;
format.size = 18;
format.align = TextFormatAlign.CENTER;
format.bold = false;
textLog.embedFonts = true;
textLog.setTextFormat(format);
this.addChild(textLog);
}
【问题讨论】:
标签: actionscript-3