Rendering of HTML text in browsers and flash text box is different in the fact that;
spaces, tabs and line brakes are ignored in browsers but are rendered in flash text box.
I faced this problem in my reference panel application and wrote the following script as a solution.

[UPDATE] included the ActionScript 3 version as well 🙂 It became lot more simpler with the regular expressions

/*
 ************************************************************
   Developed by R.Arul Kumaran [[email protected]]
   for more code keep visiting [www.luracast.com/all/blog]
 ************************************************************
 */
/* Coming Soon
*/


 */
/*
 ************************************************************
   Developed by R.Arul Kumaran [[email protected]]
   for more code keep visiting [www.luracast.com/all/blog]
 ************************************************************
 */

 String.prototype.onlyHTML = function() {
        var str = "";
        var prevWhite = true;
        for (var i = 0; i<=32;
                if (white) {
                        if (!prevWhite && (code == 9 || code == 32)) {
                                str += " ";
                        }
                } else {
                        str += this.charAt(i);
                }
                prevWhite = white;
        }
        return str;
}


 

It removes the extra spaces, tabs and also replaces line brakes with space