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 );