我正在尝试将一个文本字段放到我的舞台上,并且我已经计算出以下代码。 它似乎没有错误,但它没有出现在我放置代码的框架中。
我对此很新,所以我不确定是否可以使用动作脚本3添加文本字段。
我错过了什么至关重要的,还是我看到了完全错误的方式?
stop();
import fl.text.TLFTextField;
import flash.text.TextFormat;
//formatLoginScreenText = flst
var flst:TextFormat = new TextFormat();
flst.font = "Verdana";
flst.size = 20;
flst.align = TextFieldAutoSize.CENTER;
//The Actual TextFields
var usernameField:TLFTextField = new TLFTextField();
usernameField.x = 208.05;
usernameField.y = 209;
usernameField.width = 500;
usernameField.height = 90;
usernameField.defaultTextFormat = flst;
addChild(usernameField);
return usernameField;
var passwordField:TLFTextField = new TLFTextField();
passwordField.x = 208.05;
passwordField.y = 369;
passwordField.width = 500;
passwordField.height = 90;
passwordField.defaultTextFormat = flst;
addChild(passwordField);
return passwordField ;
答案 0 :(得分:1)
你根本没有设置文字=) 并且不需要返回一些东西。
这有效:
stop();
import fl.text.TLFTextField;
import flash.text.TextFormat;
//formatLoginScreenText = flst
var flst:TextFormat = new TextFormat();
flst.font = "Verdana";
flst.size = 20;
flst.align = TextFieldAutoSize.CENTER;
//The Actual TextFields
var usernameField:TLFTextField = new TLFTextField();
usernameField.x = 208.05;
usernameField.y = 209;
usernameField.width = 500;
usernameField.height = 90;
usernameField.text = "username";
usernameField.defaultTextFormat = flst;
addChild(usernameField);
var passwordField:TLFTextField = new TLFTextField();
passwordField.x = 208.05;
passwordField.y = 369;
passwordField.width = 500;
passwordField.height = 90;
passwordField.defaultTextFormat = flst;
passwordField.text = "password";
addChild(passwordField);
如果您希望文本可编辑,请执行以下操作:
passwordField.selectable = true;
passwordField.type = TextFieldType.INPUT;