如何在AS3中为文本字段添加样式?

时间:2014-04-07 01:28:12

标签: ios actionscript-3 flash adobe

当我按下按钮时它会显示文字,但我如何添加风格?如位置和颜色。

import flash.text.TextField;

var tf:TextField= new TextField();


convob.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void
{

tf.text="hello world";


addChild(tf);

}

1 个答案:

答案 0 :(得分:1)

这样的事情:

var format:TextFormat = new TextFormat();
format.color = 0x555555;
format.size = 18;
format.align = TextFormatAlign.CENTER;
format.bold = false;
tf.setTextFormat(format);

检查TextFormat的类引用:http://help.adobe.com/en_GB/FlashPlatform/reference/actionscript/3/flash/text/TextFormat.html