Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

ActionScript 2 - create and delete a TextArea?

I'm trying to write a simple error display object that has a method to clear the error message by deleting the textarea in which it is displayed. This code displays the error but does not remove it. This should be simple, I'm stumped. Ten points to the first one who helps me solve and understand this!

YA seems to be 'editing' the lines a bit, truncating them. Sorry about that.

objError.ShowError = function(errmsg:String)

{

objError.errordisplay = createTextField("errordisplay",getNextHighestDepth(),leftbanner,topbanner,Stage.width - leftbanner,Stage.height - topbanner);

objError.errordisplay.htmlText = errmsg;

objError.errordisplay.setTextFormat(fmtError);

objError.errordisplay.selectable = false;

};

objError.ClearError = function()

{

delete(objError.errordisplay);

};

1 Answer

Relevance
  • Favorite Answer

    I see that you are trying to store the newly created textbox in a variable name called "errordisplay ". And then you try to remove that textbox being referenced in that variable name.

    First option is create the textfield with an unique depth which does not change.i.e., do not use getNextHighestDepht() but use a numeral value such as 0 or 1 or any positive value all the time you create this textfield.

    And when you clear the error use objError.errordisplay.removeTextField();

    This will work perfectly.

    Second option is to create the text field once and just clear the text content by using objError.errordisplay.text = "";

    regards,

    Ashok Srinivasan.

    http://actionscript2actionscript.blogspot.com/

Still have questions? Get your answers by asking now.