A place to log my programming solutions.
24
Dec 08

Embedding HTML Into Flash

I recently had the opportunity to work on a website that used Flash as the front-end and using LAMP on the backend. At first this seemed like a daunting task, since my Flash experience (outside of creating simple animation tweens and using the software as a drawing tool) was limited to dropping the auto-generated code that Flash generates into an HTML page.

I had no experience whatsoever with interfacing Flash with the server. I was surprised to learn that the task wouldn’t be as difficult as I’d imagined. An SWF file can be set to load data from a server transparently, akin to AJAX’s behavior. The only hint of an HTTP request is seen in the browser’s status bar. Anyway, an SWF can query an XML file (or in my project’s case, XML-output generated via PHP) and parse that into objects that can be displayed to the user.

Whenever the SWF has to display data in a pre-defined format, for example for a biography page, I can simply send it xml in the format:

<person>
<name>Person Name</name>
<birth>20000101</birth>
<biography>Born.  Lived.  Died.</biography>
</person>

Nice and simple, the data required by the SWF can be easily represented through XML structures.

When the data is not so structured however, we can feed it into flash via XML’s <![CDATA[content here]]> value. It’s good to know that Flash can display HTML content, albeit in limited fashion. For example, CSS is not readily supported (I believe it can be done using ActionScript, and that requires work on the Flash programmer’s part). Since there’s no CSS, we have to use the “old-school” <b>, <i>, and <u> tags, as well as the dreaded <font> tag. Remember <font>? Those were the good old days. For the official reference on supported HTML tags, here’s Adobe’s “Supported HTML tags” page. Enjoy.

It’s important to note also, that when using the <b> and <i> tags, that the specified font has the bold and italic typefaces. One of the issues I ran into was that for some reason the SWF wasn’t honoring <b> and <i> tags, due to this typeface unavailability.

[Edit: updated link to Supported HTML tags]

  • StumbleUpon
  • Digg

Leave a Response

About NVNCBL and Myself

Contact Me