SWFObject 2.2 and wmode transparent
Just a quick post on a snippet of code I always forget (I think it must be my age). I use SWFObject (v2.x) to include Flash into pages, but I always forget how to embed it with a transparent background; not anymore:
1
2
3
4
5
var flashvars = {},
params = {wmode:"transparent"},
attributes = {};
swfobject.embedSWF("/swf/yourSWF.swf", "anim", "300", "200", "9.0.0","/swf/expressInstall.swf", flashvars, params, attributes);
It’s just so simple, I have no idea why I never remember it. Simply pass an object with “wmode” set to “transparent” when you call embedSWF().
On a side note you can always load SWFObject from the Google AJAX Libraries API:
1
2
3
4
<script src="https://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load("swfobject", "2.2");
</script>
It can take some pressure off your own server in serving the file and there’s a chance that the user will have the file cached from a previous site using SWFObject.
Update: Have removed the quotation marks around wmode as it was causing issues, thanks junats!