为什么在重新调整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.
更多推荐
发布评论