avorum
avorum

Reputation: 2293

part of textfield is disapearing

So I have two textfields in a AS3 program. One of them displays fine, the other one gets cut off about half way through, any idea what could have caused this? They are created with all the same parameters (except they have different text).

Sorry about the lack of detail.

var tf1 = new TextField();
tf1.text = "You scored: " + score + " points";
tf1.x = miscellaneousObjects[0].x + 50;
tf1.y = miscellaneousObjects[0].y + 50;
tf1.textColor = 0xFFFFFF;
tf1.setTextFormat(myTextFormat);
uiTextLayer.addChild(tf1);
var tf2 = new TextField();
tf2.text = "Would you like to play again?";
tf2.x = miscellaneousObjects[0].x + 50;
tf2.y = miscellaneousObjects[0].y + 80;
tf2.textColor = 0xFFFFFF;
tf2.setTextFormat(myTextFormat);
uiTextLayer.addChild(tf2);

miscelleanousObjects[0] refers to the image of a box that's supposed to be surrounding the text. As you can see they're created exactly the same.

Upvotes: 1

Views: 312

Answers (2)

Asad
Asad

Reputation: 1837

use

tf1.autoSize = TextFieldAutoSize.LEFT;
tf2.autoSize = TextFieldAutoSize.LEFT;

Upvotes: 1

bwroga
bwroga

Reputation: 5459

Textfields default to a size of 100 pixels by 100 pixels. Try explicitly setting the width of the TextField:

tf1.width = 500;
tf2.width = 500;

Upvotes: 2

Related Questions