Convert Flash-generated embed code to SWFObject format

Have you ever seen the annoying gray box around Flash content on websites? If you have, you must have done the unthinkable and used Windows Update [:O]. To make a long story short, a company called Eolas Technologies got in a yelling match with Microsoft and the two companies have since tried to make life more difficult for each other. Microsoft decided to require Internet Explorer users to click once on EVERY ActiveX control (actually anything in an EMBED or OBJECT tag) as a safety precaution. You can read more about that battle here: Microsoft tweaks browser to avoid liability | CNET News.com. The solution to this problem is to embed the object in the page dynamically - after the page is loaded. This is exactly what SWFObject by deconcept does - and it does it well! SWFObject is also capable of Flash Player version detection in Javascript and has been used on some big name sites like YouTube.

Everytime I want to use SWFObject I am annoyed that I don’t remember the syntax, so I wrote a nice little script that will convert the ┬ácode that you get when you publish in Flash into SWFObject friendly code! The script is located here:

http://devel.teratechnologies.net/swfhelp/

As an example, it will convert this HTML code:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash
/swflash.cab#version=8,0,0,0" width="100" height="50" id="flashtab" 
align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="flashtab.swf" />
<param name="quality" value="high" />
<param name="wmode" value="transparent" />
<param name="bgcolor" value="#ffffff" />
<embed src="flashtab.swf" quality="high" wmode="transparent"
bgcolor="#ffffff" width="100" height="50" name="flashtab"
align="middle" allowscriptaccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" /> 
</object>

To this SWFObject code:

<div id="swfdiv_flashtab">  
This text is replaced by the Flash movie.   
</div>  
<script type="text/javascript">  
  var so = new SWFObject("flashtab.swf", "flashtab", "100", "50",
"8.0.0", "#ffffff");   
  so.addParam("allowscriptaccess", "samedomain");   
  so.addParam("quality", "high");   
  so.addParam("wmode", "transparent");   
  so.write("swfdiv_flashtab");   
</script>

stevekamerman

COO @scientiamobile