WordPress and Flash

Typically we have always created Flash sites from scratch and used XML or, in the case of Rush.com, a custom-made CMS as the content source

For the bulk of our clients having a custom-made CMS doesn’t work with their budget so we are left with XML. This is a great option for simple updates or if the user has some modicum of web savvy but for the average person it can be daunting to update.

I have dabbled in using Drupal and creating a DruFlash type of site but found that Drupal’s interface was not as user friendly as I would like for clients.

Personally I really like how WordPress is put together – it makes sense, is easy to use and the advanced features are there but not in the way. It also seems that people in the realm of marketing and PR have at least a little experience with it so in my opinion it was the obvious choice to tie into a Flash based site.

The Issues

The first issue I ran into was the most obvious – How do I get the content out of WordPress? The answer was much simpler than I was expecting. I found a pre-existing plug-in for WordPress called Flash API. It is not for the average user as it utilizes some custom PHP and a custom class in AS3 to pull the content out of WordPress.

This is a complete tangent but I learned a while ago that there are no gold stars for re-inventing the wheel when it comes to code. If someone else has taken the time to solve your problem for you – thank them (by giving credit where you can), expand on it if you can and move on.

The second issue I ran into was – getting around limited HTML tag support in Flash HTML textfields. This took a little bit of thinking. The first thing I did was figure out what WordPress used when making something bold, italics or a different colour and balance that with what options the client wanted.

Once I knew the code that WP created, I just used some basic regular expressions and string manipulations in Flash to change the tags to ones that Flash supported.

At that point I thought I was out of the woods as far as getting the content out of WP but after uploading to the testing server I found that there were times that the content didn’t load but it was very random.

I figured out that the issue lay in how often I was querying WP. The original plan was to pull the content for a given section only when I needed it and sometimes the Flash portion of the site was loading before the content was ready and due to the way the artwork and transitions worked I couldn’t drop an event listener in to wait for it. Long story short, the section would load without content. Which is not really good web design.

So after some thinking, I decided to revamp my AS3 class to pull all of the content at once in the root swf before the site loaded where I could control the load with event listeners and incorporate some error handling and fallback options.

The upside of doing this was that once the site pulled the content we were free of WP and any potential connection issues. The downside was that the whole site needed to be reloaded to see new content but that’s a small price to pay for the increased stability.

Overall I found the process to be great. There were times when I wanted to lose my sh*t over it but I can see the benefits of building a reusable code base for this use.