Original: the best solution for correctly displaying HTML content of embedded images in Flash as3

Source: Internet
Author: User

I tried almost all the solutions to this damn problem when I was working on a project, almost collapsed, and finally found the perfect solution. Because no one gives the correct answer after searching for Chinese or English on the Internet for countless times, I 'd like to write it down here to help people who encounter this problem like me.

1. textfield + uiscrollbar method:

This method is no problem for common HTML, and it is sufficient for text to display the scroll bar, but if you just like me, there is only one sentence to introduce and add an image, you will find that the scroll bar cannot be displayed. The image is halved because the IMG image in htmltext is post-loaded. That is to say, when you add a scrollbar, the height of textfield is not enough to display the scroll bar. To solve this problem, I even tried to use the getimagerefrence method to listen to the loading events of IMG images, and then re-use uiscrollbar. Update to re-paint the scroll bar. However, unfortunately, theoretically feasible methods are useless.

2. Use textarea directly

Textarea is actually the combination above. The results do not need to be said, but they still cannot be solved.

3. Ultimate Solution: textfield + scrollpane

The final solution is to create a textfield, set its multiline and wordwrap to true, set its width, set autosize to left, and point the source of scrollpane to the textfield. Finally, the problem is solved normally. Note: Make sure to set the multiline to true. Otherwise, all your paragraphs will be merged into a paragraph. This story makes me unable to respond for half a day. Below is a short section of my as3 that implements this functionCode.

 

Code

VaR T_content: textfield = New Textfield ();
T_content.x = 0 ;
T_content.y = 0 ;
T_content.multiline = True ;
T_content.border = True ;
T_content.stylesheet = Contentstyle;
T_content.width = Box. width;
T_content.autosize = " Left " ;
T_content.condensewhite = True ;
T_content.wordwrap = True ;
T_content.htmltext = P_content;
Box. addchild (t_content );
VaR ASP: scrollpane =   New Scrollpane ();
Box. addchild (ASP );
ASP. Source = T_content;
ASP. horizontalscrollpolicy = Scrollpolicy. off;
ASP. setsize (t_content.width, 340 );

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.