如何从AS3中的另一个MovieClip更改舞台上的textField
在StatusEvent
(完整)处理程序
stage.texfield.text = "test"; //Not Working
this.parent.textfield.text = "test"; //NOt Working
提前致谢
答案 0 :(得分:2)
如何在舞台上放置文字字段?您可以按名称获取TextField的引用。
var myTextField: TextField = stage.getChildByName("someName") as TextField;
if(myTextField != null){
myTextField.text = "New text";
}else{
trace("Can't find text field on the Stage");
}
但是当你创建它时,你应该给它一个名字:
var newField: TextField = new TextField();
//code for initialisation of the text field
newField.name = "someName";
如果您在Flash IDE中创建文本字段,那么它不在舞台上,在场景上为其命名并访问它:
//Give some name for text field on scene in Flash IDE, for example: myText
myText.text = "new Text";