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);
dummy.removeTextField();
// 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
},
function(t){
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
Comments
Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?



Most Visited Entries
Experiments
Lectures
Contact
Backlog
In Love with
Powered by