以下是本人写TextField垂直居中的时候遇见的闹心事!
var textField:TextField = new TextField();
textField.autoSize = "center";
textField.multiline = true;
textField.wordWrap = true;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
textField.y = 100;
textField.x = 200;
this.addChild(textField);
如果textField属性书写顺序为以上排列, 运行效果如下:
var textField:TextField = new TextField();
textField.autoSize = "center";
textField.y = 100;
textField.x = 200;
textField.multiline = true;
textField.wordWrap = true;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
this.addChild(textField);
如果textField属性书写顺序为以上排列, 运行效果如下:
var textField:TextField = new TextField();
textField.autoSize = "center";
textField.multiline = true;
textField.wordWrap = true;
textField.y = 100;
textField.x = 200;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
this.addChild(textField);
如果textField属性书写顺序为以上排列, 运行效果如下:
var textField:TextField = new TextField();
//textField.autoSize = "center";
textField.multiline = true;
textField.wordWrap = true;
textField.type = TextFieldType.INPUT;
textField.border = true;
textField.borderColor = 0xff0000;
textField.y = 100;
textField.x = 200;
this.addChild(textField);
如果textField属性把autoSize属性去掉, 运行效果如下:
这个东西浪费了我好几个小时, 真是不知该如何表达我的心情了!!!