Flash and compliance

Flash coders and HTML developers are often (in professional situations at least) two different groups of people (at 450quid for Flash MX it's not really a great area for casual experimentation) - and so flash features tend to be coded into the HTML as a black box "to be added later". The code to do so tends to be dropped into place without much thought, with some vague understanding that "IE does it this way, Mozilla does it another way, and somehow this stange combination of object and embed tags will make it work". In fact I've seen many cases where someone has used the standard code and only changed one set of parameters (usually for IE), showing that for many the tags are completely incomprehensible.

So what *are* those tags, how do they work, and why does there need to be yet another article about this on the web?

Well, I'm writing this to record the day's battles with adding flash to a new site in a standards-compliant manner. The problem is that the 'embed' tag traditionally used for the mozilla part of the code does not exist in the HTML 4.01 standard. So why does mozilla, known as 'the standards-compliant browser', need it?

Answer: it doesn't. The use of 'embed' is purely historical, and primarily used because it's believed that the 'object' tag can't work in Mozilla. In fact it works fine, just not in the same way as in IE. And the object tag is specified by the W3C to degrade gracefully any time it doesn't work fully. If the object itself cannot be displayed, then the code inside the object tag (excluding parameters) is displayed instead. And multiple objects can be stacked inside each other, such that the first one recognised by the browser will be displayed and the rest ignored.

That code, of course, looks much like:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
WIDTH="200" HEIGHT="100" id="flashmovie1">
<PARAM NAME="movie" VALUE="logo.swf">
<PARAM NAME="quality" VALUE="high">
<PARAM NAME="bgcolor" VALUE="#FFFFFF">
<EMBED src="logo.swf" quality="high" bgcolor="#FFFFFF"
WIDTH="200" HEIGHT="100"
NAME="flashmovie1" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">
</EMBED>
</OBJECT>


This works in Mozilla, but the object tag syntax used by IE (which is, apparently, strictly wrong) isn't understood - so mozilla degrades correctly and displays the tag inside it instead - which is the 'embed' tag. Mozilla understands this as a legacy tag, and displays the specified flash movie correctly. However, it can use the object tag, as specified in Drew McLellan's article on standards-compliant flash embedding which provided the best solution I've yet found.

Having read that article, I wondered why I couldn't wrap one flash-object tag (the one for Moz) inside the other (the one for IE). After all, the standard (linked above) seems to indicate that this should work.

The code would have to be something like:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase= "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
WIDTH="200" HEIGHT="100" id="flashmovie0">
<PARAM NAME="movie" VALUE="logo.swf">
<PARAM NAME="quality" VALUE="high">
<PARAM NAME="bgcolor" VALUE="#FFFFFF">

<OBJECT type="application/x-shockwave-flash"
WIDTH="200" HEIGHT="100" id="mozflashmovie0"
data="logo.swf">
<PARAM NAME="quality" VALUE="high">
<PARAM NAME="bgcolor" VALUE="#FFFFFF">

</OBJECT>

</OBJECT>


And - perhaps suprisingly - it works. It works in Firefox (1.0.4), IE/Mac (5.2.3/OSX), Opera/Mac (8.0b/OSX). It works on XP in Opera 7.54 and Firefox 1.0.4. (I don't have any older test systems at home, unfortunately).
And then I checked in IE6/Win, and it all went to hell. Because, while IE/Mac handles the nested object tags perfectly, IE/Win fails dismally. It reserves space for both objects in sequence - leaving large blanks on the page. In other words, it fails at the first, most basic hurdle in the W3C spec:
"If you can display the outer object, do so, OTHERWISE display the inner tag". Trivial logic, clearly stated. And yet, far too much for the latest offering from world's "leading" software company.

So, stick with the McLellen compromise for the moment - and keep weaning your users away from IE.
Posted by parsingphase, 2005-05-31 20:29

Anonymous user

Login

Blog

Contact

I'm currently available for contract work in London as a Senior PHP Developer. Contact me for a CV, rates, or a chat.

Twitter @parsingphase
Email richard@phase.org
Github parsingphase
LinkedIn Richard George
Flickr parsingphase