Wednesday, July 1, 2009

Standard XHTML and Flash

With the status of standardization of web "technologies" in such a sad state, "Web 2.0" really doesn't mean much on the code side.


I've found something interesting regarding standardized Flash support: a way to include it in strict XHTML (not "transitional"). It involves creating a dummy Flash movie that loads the first one. I found it in this blog entry..

The XHTML code for the movie is as follows, assuming the movie we actually want to load is movie.swf:

<object type="application/x-shockwave-flash"
data="c.swf?path=movie.swf">
<param name="movie"
value="c.swf?path=movie.swf" />
</object>

c.swf is a fairly simple bit of ActionScript:

_root.loadMovie(_root.path,0);

According to the article, it loads the movie as expected and streams it. One caveat is that it won't operate properly if the browser doesn't support Flash. To fix that, something like this is necessary:

<object type="application/x-shockwave-flash
data="c.swf?path=movie.swf">
<param name="movie"
value="c.swf?path=movie.swf" />
<img src="noflash.gif" alt="" />
</object>

Of course, the img tag can be replaced with any "alternate" element to be displayed when there's no Flash support. Pretty cool.

Post a Comment