Flash and DHTML
April 3, 2007 04:35 pm
Since most of my duties revolve around the PHP/database solutions I've rarely had to do much integration with Flash (despite our company's strong ties to it). A recent project had me dabbling into the realm of some of my coworkers so I'd figure I'd throw some pointers out there for us backend dev guys. Normally when embedding flash objects we use the swfobject script from Geoff Stearns to handle flash installation and version checking. One of the problems when combining DHTML (especially DHTML menus) and flash is the problem with flash appearing over your DHTML layers no matter what z-index values you assign them. The quick fix for that is to set the wmode parameter for your flash object to "transparent." Using the swfobject you would just call the addParam("wmode", "transparent"); member function of your instantiated swfobject.
Another small thing to watch out for is when using the ExternalInterface with flash to expose functions within flash to javascript you'll need to use the id you specify when you instantiate the swfobject, not the id for the div that the object writes to. For example if you were trying to access an exposed function named "setAudio" for an swf created with the following code:
<script type="text/javascript">
<!--
var so = new SWFObject("flash/myflash.swf", "flashPlayer", "895", "263", "8", "#ffffff");
so.addVariable("menu", "false"); so.addParam("wmode", "transparent");
so.addParam("allowScriptAccess", "always"); so.write("mainFlash");
//-->
</script>
Your javascript would be accessing "flashPlayer," not "mainFlash."

