all groups > flash actionscript > may 2005 >
You're in the

flash actionscript

group:

Using removeTextField()


Using removeTextField() DIszastre
5/13/2005 12:00:00 AM
flash actionscript:
Can anyone explain why I cannot get the "removeTextField()" to work all the
time?? I am creating a TextField at runtime using the ActionScript:

this.createTextField("cMagnitude",this.getNextHighestDepth(),546,195,100,30);

the TextField is being successfully created. Then, at a later frame I have
input the script:

this.cMagnitude.removeTextField();

this seems incredibly simple, but the text box will not dissapear when the
frame is executed. Any answers??
:confused;
Re: Using removeTextField() ...helmut
5/13/2005 3:08:29 PM
It works here.

Try creating a new blank file and testing the code by itself. If it works I
would say something is wrong with your Movie.

--
....helmut
helmutgranda.com



[quoted text, click to view]

Re: Using removeTextField() Jack Trades
5/23/2005 12:00:00 AM
I was wondering if you are using functions in your code. I am trying to do
something similar and I am having the same trouble (and I am also using
functions). I found that if I change my_mc.getNextHighestDepth() to a 1 then
the removeTextField works properly.

Sample of my code:

function createTextBlock(x:Number, mainClip_mc:MovieClip):Void
{
mainClip_mc.createTextField("intersection"+x+"_txt",
mainClip_mc.getNextHighestDepth(), 0, 0, 70, 20);
mainClip_mc["intersection"+x+"_txt"].text = "Intersection "+(x+1);
}

function removeTextBlock(x:Number, mainClip_mc:MovieClip):Void
{
mainClip_mc["intersection"+x+"_txt"].removeTextField();
}

Then I just call:

createTextBlock(0,_root);
this.begin_btn.onRelease = function(){
removeTextBlock(0, _root);
}

As I said before, this works when I physically choose the depth as 1.
Unfortunately, I have many Text Fields to create and I need to use
getNextHighestDepth().

I hope you have found your solution and you or somebody else can help me with
my problem.

-Troy

Re: Using removeTextField() fuGood
6/17/2005 12:00:00 AM
Hi.
I have the same probloms. My button will do anything - including altering the
text field!! - but will not remove it. I wonder if indeed it is something to do
with functions - I use them everywhere.
God, there is so much to dislike in the new actionScript even without the
bugs. Geez!
Re: Using removeTextField() rlc5611
6/17/2005 12:00:00 AM
Are you by chance using any Flash UI components?

Place this at the very end of your action script:

for (thingy in _root) {
trace("hi I name is " + thingy + " and my depth is " +
_root[thingy].getDepth());
}

test the file and cut and paste the result you get
Re: Using removeTextField() fuGood
6/17/2005 12:00:00 AM
You are right! I forgot about this stupid thing!
My solution is to use something like this:

var nDepth:Number = this.getNextHighestDepth() - 20;
this.createTextField("tDataMassage", nDepth, 222, 35, 500, 335);

Personally, I think that Macromedia had a large team of very smart man that
gathered before this Flash release, with one goal: mess actionScript as much as
possible. Hey, they did pretty good job!
Re: Using removeTextField() rlc5611
6/17/2005 12:00:00 AM
If I were you I would investigate a more convenient solution. Since you did not
cut and paste, I can only guess what you found but, just as an example, you
might try something like:

focusManager.swapDepths(-1001);
reserved.swapDepths(-1002);

get those clips down to depths where they will not interfere with
getNextHighestDepth. I have also tried removing the focusManager clip but found
that it does have consequences (some - but not all - of them are actually good
consequences BTW).
Re: Using removeTextField() mandingo
6/17/2005 12:00:00 AM
as with most of these complaints... it can usually be traced back to a
reference path issue.

Jack trades... yours can be fixed in one place...
change :

this.begin_btn.onRelease = function(){
removeTextBlock(0, _root);
}

to:

this.begin_btn.onRelease = function(){
this._parent.removeTextBlock(0, _root);
}

you are inside a different timeline to where the function resides... you need
to get outside one _parent and it will work.

I haven't seen enough code from the original poster to see exactly where his
'this' is when he is trying to remove the textField but I am guessing from the
fact that it fails, he isn't on the same timeline as when it was created...
either that or the remove is inside a movieClips onRelease event and the this
is referencing the buttons timeline and not the parent as explained above.

I hope that helps.

cheers,

Re: Using removeTextField() fuGood
6/17/2005 12:00:00 AM
mandingo:
As far as my case goes, the blame is that using components subtoge the smooth
operation of the getNextHighestDepth().

rlc5611:
Thanks, mate! I'll try to figure out what your work-around, but mine is very
simple (even simplistic) - since the problom is with the max number, I just
subtract something from it, say 20:
var n = this.getNextHighestDepth() - 20;

and then use the variable instead of the
Re: Using removeTextField() fmdano
8/25/2005 12:00:00 AM
Below is the code I am trying to use to delete a text fields when a user
selects a new set of data. If there is a bug within the system, is there a
good work around for deleting the text fields?
The text fields are being created dynamically each time a user selects a
button which is contained in a scroll pane.
I have to delete the text fields before the new ones are created, or the new
ones will create over top the first ones.

ActionScript:
var numLen:Number=Number(_global.prevItmTotal);
for(var r:Number = 0; r < numLen; r++){
reserveInfo_mc["item_" +(r+1)].removeTextField();
reserveInfo_mc.removeTextField(["item_" +(r+1)]);
}


how I create the text fields:

var counter = 0;
var num1:Number=Number(this.ButtonText_txt.text);
var depth = num1;

for(var q:Number = 0; q < this.itemTotal; q++){
var x = 0;//445
var y = 150;//205
reserveInfo_mc.createTextField("item_" +(q+1), depth, x, y+counter, 100,
20, {fontFamily:"Arial", fontSize:"10"});
reserveInfo_mc["item_" +(q+1)].font = "arial";//getNextHighestDepth()
reserveInfo_mc["item_" +(q+1)].text=this["item_" +(q+1)];
counter += 15;
depth = depth + 1; //+=
}


Please help me!!!

dan
Re: Using removeTextField() Leppy
11/9/2005 12:54:54 PM
Well, i have been having problems with this also, but i found a very easy
solution that works perfectly for me:

Making a textfield:

function Output(X,Y,T,C) //X position by box, Y position by box, Text, Color
{
TextStyle = new TextFormat();
TextStyle.color = C;
TextStyle.size = "20";
TextStyle.font = "_typewriter";
TextStyle.bold = true;
this.createTextField("NewText" + TextBoxCode, TextBoxCode, X, Y, (T.length *
13)+2, 26.6)
this["NewText" + TextBoxCode].html = true;
this["NewText" + TextBoxCode].htmlText = T;
this["NewText" + TextBoxCode].setTextFormat(TextStyle);
TextBoxCode = TextBoxCode+1;
}

Removing the texboxes (This is also in a function):

while(TextBoxCode <> 0)
{
this["NewText" + (TextBoxCode-1)].removeTextField();
TextBoxCode = TextBoxCode-1;
}

NOTE: I TextBoxCode as depth setter, now the reason it did not work before is
because i did not subtract 1 when i tried to remove the textfield >
this["NewText" + (TextBoxCode-1)]

Maybe that is what is going on for you guys...for me this works perfectly
AddThis Social Bookmark Button