为什么在重新调整ActionScript 3的阶段时,第二行文本会消失?(Why does second line of text vanish when stage is being re

编程入门 行业动态 更新时间:2024-10-05 15:35:28
为什么在重新调整ActionScript 3的阶段时,第二行文本会消失?(Why does second line of text vanish when stage is being re-sized ActionScript 3?)

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

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);

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

I have this code. It creates two lines of text on the stage but when ever the stage get re-sized the second line of text can vanish when the stage is being scaled. Does anyone know why this is happening? Thank you for your help in advance!

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);

The sprite is then added to the stage.

最满意答案

请尝试以下代码:

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);

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

Try the following code :

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);

Notice the addition of the auto size, that seems to fix your problem.

更多推荐

本文发布于:2023-07-09 10:23:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1085613.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阶段   line   ActionScript   stage   vanish

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!