开发者

AS3 : How to show image within text in same line

开发者 https://www.devze.com 2023-02-12 04:53 出处:网络
I would like to show some images and text in the same line. The text and image is completely dynamic. At first I thought to use htmlText property of TextField as img tag is supported. Something like t

I would like to show some images and text in the same line. The text and image is completely dynamic. At first I thought to use htmlText property of TextField as img tag is supported. Something like this:

var tf:TextField = new TextField();
tf.htmlText = "before img <img src='img.png'> after image";
addChild(tf);

But I found that the image is showing in the next line, not in the middle of two text segments. Then after checking the manual of TextField I have found that this is the docu开发者_StackOverflow中文版mented behavior that the image will be shown on the line following the img tag.

So what is the best way to do this? Note that the text and position of images are completely dynamic.

I understand that it is possible to split the input in a series of texts and images and then position them calculating the text and images width. In other words parse the input ourselves.

Is there any better way to do this? Or is there any library available that does this parsing?


Hail, Taskinoor.

You need use TLF.
You can follow this link that describe even more that you want.

Edit: I'm assuming you are using Flex (TextFlow).
Don't know if it is possible directly on Flash with Flex SDK4...
Maybe you'll need TLF2 (Flex SDK 4.5 Hero)

0

精彩评论

暂无评论...
验证码 换一张
取 消