Handling HTML Entities in XML Passed to Flash Dynamic Text Fields

Filed under: Flash — Allistair @ 2:01 pm

Today I had to solve the problem of HTML entities such as ' showing their full entity-selves when injected dynamically into dynamic text fields.

The entities originated from an XML input stream fed into the Flash movie.

Quite a few folk out there seem to have developed string search and replace functions, but these are limited by the anticipated characters.

I found a much simpler method was just to set the dynamic text field instance’s .html attribute to true, and then inject the text into the .htmlText rather than the .text attribute. Flash apparantly then displays the characters properly.

And I should add that the dynamic text field in question still has anti-aliasing applied in case any of you are worried that using the html attributes do not support it.

Happy days.