Hola! It’s been a while. I’ve got another gripe, and this time it’s with Flash embed code!
Most of the embed code I see for Flash movies is invalid, usually containing the non-existent embed element or some-such. Even the code provided by YouTube for embedding videos contains embed. This can easily be thrown out and will—probably most of the time—instantly make your code valid.
Here’s an example (in XHTML) of a valid Flash embed that works in at least IE6+, Firefox, and Safari:
<object data="flash.swf" type="application/x-shockwave-flash" width="320" height="240">
<param name="movie" value="flash.swf" />
</object>
That’s all there is to it. Adjust the parameters and add additional param elements as necessary. If your Flash movie requires variables, just add an extra param as follows:
<param name="flashvars" value="arg1=foo&arg2=bar" />
If you place additional elements inside the object element, it will act as a fallback, displaying if the Flash plugin isn’t installed. For example:
<object data="flash.swf" type="application/x-shockwave-flash" width="320" height="240">
<param name="movie" value="flash.swf" />
<img src="fallback.jpg" alt="Flash Didn't Load!" />
</object>
That’s all for now. Happy coding!





Valid Flash Embed and Preloaders in Internet Explorer
Hello once again, web friends. Today I bring tidings of Flash preloaders and validity.
You may have noticed that with the embed code from my YouTube article that Flash movie preloaders don’t work in Internet Explorer, and the movie has to load entirely before it even displays at all. This is because Internet Explorer requires a different attribute and the removal of another in the
objecttag to let preloaders work properly. However, with different attributes, the Flash movie will not display at all in Firefox, so we must use Internet Explorer’s conditional comments to utilize two different openingobjecttags. Behold:The first line is the original that works in both IE and Firefox but doesn’t allow preloaders in IE. The second is the IE-only method that works with preloaders. Note the lack of a
dataattribute and the addition of aclassidattribute.Well, there you have it. Venture forth and embed Flash validly with preload animations!
Tags: Conditional Comments, Embed, Firefox, Flash, Internet Explorer, Preloader, Web Development, Web Standards, XHTML
Posted in Web Standards | 1 Comment »