2014-03-13 94 views

回答

2

你如何将文本字段在舞台上

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"; 
相关问题