Skip to main content
Inspiring
August 18, 2010
Answered

removeTextField();

  • August 18, 2010
  • 1 reply
  • 816 views

Is there a way to remove all the text fields which was created? I used instance.removeTextField() but still I see some text boxes.

In my fla when I go back and forth between frames I still see there are text boxes by the text cursor appearance. I'm having trouble because the buttons can not be clicked when the text fields are there.

I'm using several of these in different frames.

this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);

This topic has been closed for replies.
Correct answer kglad

create an array to store your textfields and store their references in that array.  then loop through that array (from end to beginning) and remove them when you want:

// these lines should execute once only at the start of your fla to initialize tfA and removeTF()
var tfA:Array = []; 
function removeTF(){
for(var i:Number=tfA.length-1;i>=0;i--){
tfA.removeTextField();
}
}

// then when you create tf's, store them:

this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);

tfA.push(scroll_txt);

tfA.push(newszlatest);

// then when you want to remove them all, call removeTF():

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 18, 2010

create an array to store your textfields and store their references in that array.  then loop through that array (from end to beginning) and remove them when you want:

// these lines should execute once only at the start of your fla to initialize tfA and removeTF()
var tfA:Array = []; 
function removeTF(){
for(var i:Number=tfA.length-1;i>=0;i--){
tfA.removeTextField();
}
}

// then when you create tf's, store them:

this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);

this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);

tfA.push(scroll_txt);

tfA.push(newszlatest);

// then when you want to remove them all, call removeTF():

Inspiring
August 18, 2010

Thank you Kglad.

Also how can I set a font type when using this.createTextField?

kglad
Community Expert
Community Expert
August 18, 2010

create a textformat instance and assign it a font.  then assign the textformat to your textfield.

to have this work for all users, you'll need to embed your font.  do you know how to embed a font?