Multiple paragraphs and HTML text in AS3.0

Hi everyone,

'Tis my first post here on Kirupa. I’ve been coding in Flash since Flash 4’s pre-ActionScript language, and whilst I pretty much had AS1.0 down pat and half-paid attention to AS2.0 where possible, AS3.0 is giving me a good chance to relearn a lot of stuff. Naturally, I’m running into problems.

At the moment, I’m battling with Text Fields, specifically with multiline paragraphed HTML text that is dynamically created. In my example, I create one TextField programmatically, and I have a second which I have placed, sized and named manually.

Here is my code:


import flash.text.TextField;
function testTextField ()
{
 var myTextField:TextField  = new TextField();
 
 myTextField.htmlText = "<p><b>Paragraph 1</b></p><p>Paragraph 2</p>";
 myTextField.autoSize = TextFieldAutoSize.LEFT;
 myTextField.multiline = true;
 
 stage.addChild(myTextField);
}
testTextField();
placedBox.htmlText = "<p>Paragraph 1</p><p>Paragraph 2</p>";

Unless I add in line breaks (

) into the htmlText between the p tags, Flash will not break lines as expected. However, the htmlText for the placed text box works properly.

Am I missing something?

Cheers,

Mike