所以我正在尝试使用align来集中文本域中的文本
var inputFieldOne:TextField= new TextField();
inputFieldOne.width= 150;
inputFieldOne.height= 50;
inputFieldOne.x= 180;
inputFieldOne.border= true;
inputFieldOne.type= "input";
inputFieldOne.restrict= "0-9";
inputFieldOne.maxChars= 1;
inputFieldOne.background= true;
inputFieldOne.backgroundColor= 0x00FF00;
inputFieldOne.align = TextFormatAlign.CENTER;
inputFieldOne.defaultTextFormat = new TextFormat("verdana", 45);
我收到此错误:
1119: Access of possibly undefined property align through a reference with static type flash.text:TextField.
帮助?
答案 0 :(得分:1)
TextField
没有align
属性。您可能会将其与具有该属性的TextFormat
混淆。
尝试以下方法:
var textFormat:TextFormat = new TextFormat("verdana", 45);
textFormat.align = TextFormatAlign.CENTER:
var inputFieldOne:TextField= new TextField();
inputFieldOne.width= 150;
inputFieldOne.height= 50;
inputFieldOne.x= 180;
inputFieldOne.border= true;
inputFieldOne.type= "input";
inputFieldOne.restrict= "0-9";
inputFieldOne.maxChars= 1;
inputFieldOne.background= true;
inputFieldOne.backgroundColor= 0x00FF00;
inputFieldOne.defaultTextFormat = textFormat;