0

我有这个代码。它在舞台上创建了两行文本,但是当舞台重新调整大小时,第二行文本可能会在舞台缩放时消失。有谁知道为什么会这样?提前谢谢你的帮助!

var text:TextField=new TextField();
var textFormat:TextFormat = new TextFormat();
textFormat.color=0x000000;
textFormat.size=45;
textFormat.bold=true;
textFormat.font="Impact";
textFormat.italic=true;
text.x=8;
text.y=5;
text.width=200;
text.text = "Line One\nLine two";
text.setTextFormat(textFormat);
text.height=text.textHeight +4;
sprite.addChild(text);

然后将精灵添加到舞台上。

4

1 回答 1

0

试试下面的代码:

var text:TextField=new TextField();
var textFormat:TextFormat = new TextFormat();
textFormat.color=0x000000;
textFormat.size=45;
textFormat.bold=true;
textFormat.font="Impact";
textFormat.italic=true;
text.x = 8;
text.border = true;
text.y=5;
text.width=200;
text.text = "Line One\nLine two";
text.setTextFormat(textFormat);
text.autoSize = TextFieldAutoSize.LEFT;
sprite.addChild(text);

请注意添加自动大小,这似乎可以解决您的问题。

于 2013-03-01T21:39:44.830 回答