December 18, 2002
Fixing Textfield.htmlText Bug

Perhaps you haven't noticed it before, but there is a little bug in the .htmlText property of textfields: whitespaces between html tags are automatically removed. You can prevent that by using   instead of spaces, but Casper Schuirink has presented a nice fix on Flashcoders which replaces the original .htmlText property with a fixed version:

// initialize the getter/setter properties of TextField
createTextField("dummy", 1, 0, 0, 0, 0);
// kill the built-in htmlText
delete TextField.prototype.htmlText;
// restore the built-in htmlText, but with the name of htmlText2 (or another name).
TextField.prototype.addProperty("htmlText2", ASnative(104, 19),ASnative(104, 20));
// create a new, custom htmlText getter/setter variable
TextField.prototype.addProperty("htmlText", function(){
trace("get " + this.htmlText2);
return this.htmlText2; //<- how to call the original getter
trace("set " + t);
this.htmlText2 = t.split(" ").join("&nbsp;"); //<- how to call the original setter

Posted at December 18, 2002 04:47 PM | Further reading
Post a comment

Email Address:



Remember info?

Thank you!

Most Visited Entries
Sketches, Works & Source Code
In Love with
Powered by
Movable Type 2.661

© Copyright Mario Klingemann

Syndicate this site:
RSS 1.0 - RSS 2.0

Quasimondo @ flickr
Quasimondo @ LinkedIn
Quasimondo @ Twitter
Quasimondo @ Facebook
Quasimondo @ MySpace
Quasimondo is a Bright
Citizen of the TRansnational Republic
My other blog in german

My family name is written Klingemann,
not Klingelmann, Klingeman, Klingaman, Kingemann,
Kindermann, Killingaman, Klingman, Klingmann, Klingonman
Klingemman, Cleangerman, Klingerman or Kleangerman

profile for Quasimondo at Stack Overflow, Q&A for professional and enthusiast programmers