Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why is a space always added after each <img> ?

New Here ,
Oct 18, 2013 Oct 18, 2013

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.

TOPICS
ActionScript
390
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 22, 2013 Oct 22, 2013
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines