Copy link to clipboard
Copied
Hello,
I have an input TextField, in which I want to add text and images. But each time I add a new image in the textField (via an <img> tag), a space character is added after every other <img> in the TextField. Why is that ?
You can test it for yourself :
function test():void
{
var tf:TextField = new TextField();
tf.multiline = true;
tf.text = "Hello World";
trace("1/ tf.length", tf.length);
trace("1/ tf.text", tf.text);
trace("1/ tf.text.length", tf.text.length);
trace("1/ tf.htmlText", tf.htmlText);
trace("1/ tf.htmlText.length", tf.htmlText.length);
var htmlText:String = tf.htmlText;
htmlText += "<img src='image.gif' id='0'/>";
tf.htmlText = htmlText;
trace("2/ tf.length", tf.length);
trace("2/ tf.text", tf.text);
trace("2/ tf.text.length", tf.text.length);
trace("2/ tf.htmlText", tf.htmlText);
trace("2/ tf.htmlText.length", tf.htmlText.length);
htmlText = tf.htmlText;
htmlText += "<img src='image.gif' id='1'/>";
tf.htmlText = htmlText;
trace("3/ tf.length", tf.length);
trace("3/ tf.text", tf.text);
trace("3/ tf.text.length", tf.text.length);
trace("3/ tf.htmlText", tf.htmlText);
trace("3/ tf.htmlText.length", tf.htmlText.length);
}
Before the first image, the text equals "Hello World" (as expected)
Before the second image, the text is "Hello World\r "
And after the second image, it is "Hello World\r \r "
So there are two spaces after the first image. And if you add a few images in the initial htmlText, they will have two more spaces at the end of the function.
Does anybody knows why is it, how to disable this behavior, or simply fix it ?
A big thanks to the one who can help me, I'm really stuck with this.
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now