Esotropiart

Blog

first last

SWFObject, the Solution to Flash Woes

Each and every technological advance in the area of web design comes with a gotcha. It feels like we as web developers and designers are stuck in about 1990, like Phil in Groundhog's Day we are stuck in a rift in time. We are promised progress by a host of new ideas. None of them ever seem to be released, or fully supported across browsers. I see this mostly as the fault of browser companies. The primary challenge of a developer is not to learn a language construct or specification. No, this is easy. The challenge is to learn the caveats of each browser and how bad their support for the technology is. This is a ridiculous limitation, and it seems to be an eternally broken record. Adding new technologies or expanding functionality of older technologies is pointless since the major browsers are lagging 10+ years behind. Ok, in all fairness, many mainstream browsers are relatively up to speed (Opera, Firefox - get them, use them!). The one browser that is still tragically used by 90% of users, Microsoft Internet Explorer, is the primary culprit and is single-handedly holding back all advancement in web technology. Every designer knows this, and we'd all be much happier if Microsoft gracefully bowed out and let those who know what they are doing make timely advancements.

All that said, I am first to admit that you learn something new every day. The area of web development involves such a variety of ever-changing technologies that there's always room for improvement or learning. I'm not a currently a Flash animator. It is a technology I've dabbled with here and there, but never pursued full-bore (funny expression). I'm a standards compliant purist on and off and have been on a bare bones do-everything-with-css pitch for quite a while. Frustrated with the lack of support for anything advanced or useful in CSS, I tend to circle back to using Javascript and other more rich media alternatives from time to time.

A few days ago I implemented a free Flash tool called Zoomify in select areas of my site. Little did I know at the time that embedding the movie as instructed would wage war with my previously solid compliance with W3C standards. When I tried validating a page where the Flash movie appeared, I received a host of validation errors.

Turns out that all this time, since Macromedia Flash (now Adobe) became a mainstream web design tool, the standard way to include an animation in a web page has been entirely illegal as far as W3C is concerned. Everyone has been embedding objects for years with little concern to the broken syntax or tags used. Even publishing straight from Flash produces this bad code!

Without going into severely boring detail (especially since others have done all the research and writing already - see references at bottom), simply put, the <EMBED> HTML tag used all these years doesn't in fact exist. I don't know who came up with it, but it started being used outside of any HTML specification. If you look at most Flash code, you will find a bunch of nested, redundant code. All this is to make things "happy" in a number of browsers, while all the while breaking dozens of rules.

Thanks to Geoff Stearns, there is now a way to include Flash files on a web page while satisfying all of the strictest standards perfectly. The only "downside" if you want to call it that is heavy reliance on Javascript to make it all work. In my opinion, if we are breaking the "purist code" by introducing Flash, it's no "worse" to assume Javascript is enabled (not that either is bad, but they are certainly not purist as far as XML, perfect markup based technologies go). At least Javascript is generally an accepted standard and is mostly harmless. Besides, Geoff's SWFObject provides alternative content if Flash is not installed or if Javascript is disabled. It is basically the best solution available.

I followed the very well laid out instructions for using SWFObject and magically all my W3C validation errors disappeared - every last one! Seriously, if you are a web developer and use Flash in any way, shape or form, you should consider this method. You will find that the script supports even most advanced Flash functionality, like passing parameters to ActionScript, for example.

To read more about the Flash embed validation problem, see these well written articles on the subject:

first last