В настоящее время я создаю текстовые поля в цикле for, хотя в этом примере создается только один TextField.
Мои вопросы: как удалить дочерний элемент TextField в другой функции?
Что я в основном делаю, так это создаю Textfield, addchild в контейнер -> затем контейнер в другую позицию -> затем removechild и другой текст в контейнере. Я пробовал что-то вроде:
removeChild (getChildByName (myTextField2));
edit: возможно, решение для меня могло бы также просто иметь возможность изменить текст TextField на что-то другое, вместо удаления его и добавления нового.
public function handleTextFrames(numberOfFrames:Number, textFrame1:String, textFrame2:String, textFrame3:String, textFrame4:String):void
{
var textArray:Array = new Array(textFrame1,textFrame2,textFrame3,textFrame4);
// Creating font instance
var garageInstance:Font = new garage();
//Creating the textfield object and naming it "myTextField"
var myTextField:TextField = new TextField();
//Here we add the new textfield instance to the stage with addchild()
textContainer.alignContainer1.addChild(myTextField);
//myTextField.width = 930;
myTextField.embedFonts = true;
myTextField.multiline = true;
myTextField.wordWrap = false;
myTextField.selectable = false;
var myText:String = textArray[0];
myTextField.htmlText = myText;
//This last property for our textfield is to make it autosize with the text, aligning to the left.
myTextField.autoSize = TextFieldAutoSize.LEFT;
//This is the section for our text styling, first we create a TextFormat instance naming it myFormat
var myFormat:TextFormat = new TextFormat();
//Embedding font
myFormat.font = garageInstance.fontName;
myFormat.color = 0xffffff;
myFormat.size = 60;
myFormat.align = TextFormatAlign.CENTER;
//Now the most important thing for the textformat, we need to add it to the myTextField with setTextFormat.
myTextField.setTextFormat(myFormat);
myTextField.y = textContainer.alignContainer1.height * 0.5 - myTextField.textHeight * 0.5;
myTextField.x = payoffContainer_mc.width / 2 - myTextField.textWidth / 2;
}