繁体   English   中英

如何在as3中从另一个MovieClip更改舞台上的textField?

[英]How to change the textField on the Stage from Another MovieClip in as3?

如何从AS3中的另一个MovieClip更改舞台上的textField

StatusEvent (完成)处理程序中

stage.texfield.text = "test"; //Not Working
this.parent.textfield.text = "test"; //NOt Working

提前致谢

如何在舞台上放置文字字段? 您可以按名称获取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";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM