I had one hell of a time trying to figure out why my paragraph breaks (<p>) and line breaks (<br>) were not working when I was using htmlText in Flash CS3 with ActionScript 3.0. All of the other HTML tags that are allowed by Flash worked fine, but those two break tags just would do anything. I had created a TextField variable called “info” and all the code checked out but there was one very important thing that I needed to put in place before it would all work the way I needed it to.

Here is the code that wouldn’t work:

var info:TextField = new TextField();
info.htmlText = "First line. <br> Second line. <br> Third line.";
addChild(info);

Here is what is should have looked like:

var info:TextField = new TextField();
info.multiline = true;
info.htmlText = "First line. <br> Second line. <br> Third line.";
addChild(info);

Why wasn’t my original code working? Well, to make sure that the HTML tags for paragraph breaks and line breaks would function properly, I needed to set the TextField’s multiline parameter to “true”. Just one tiny line of code and then everything worked perfectly. I hate it when that happens!