Wednesday, December 03, 2008

Absolute Best Way to Embed Flash in HTML

*update- doesn't seem to work with Google browser... not sure about safari. i'll update if i get a fix

This is the best way to embed flash into a webpage without javascript. It is a Markup Only solution and because it does not use the embed tag, it will validate.

The HTML object method (nested objects + IE conditional comments):

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="smix" codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab" height="30" width="100">
<param name="movie" value="file.swf">
<param name="wmode" value="transparent">
<param name="allowScriptAccess" value="sameDomain">
<!--[if !IE]>-->
<object name="smix" type="application/x-shockwave-flash" data="file.swf" height="30" width="100">
<param name="wmode" value="transparent">
<param name="allowScriptAccess" value="sameDomain">
</object>
<!--<![endif]-->
</object>


Here is a compatability chart for this method from the flash test suite by Bobby van der Sluis.

BrowserIE 5, 5.5, 6IE 7, 8b2FF 1*, 2*, 3*Moz 1.7*Saf 1.3, 2, 3*Chrome 0.2Opera 9*, 9.5*
Basicyesyesyesyesyes
Streamingyesyesyesyesyes
Paramsyesyesyesyesyes
Communicationyesyesyesno fscommandno fscommand




Since I require javascript communication, I was a little worried about Safari support but then realized that I use ExternalInterface instead of the old flash way to communicate with javascript called fscommand.

Flash 8 uses ExternalInterface to do javascript communication without using SWLiveConnect. This was a always a problem with Safari using the Object code above but no more with Flash 8 and up.

Recommendations to use SWFObject are all over the forums and is well promoted but it is too much overhead for my taste. Just remember that IE7 and under will require an extra click from the users unless you use one of the javascript methods. This is due to the stupid Ebola patent that claimed rights to HTML embed technology.
Post a Comment