I've been using 1.1 (I think) for a while, but started getting inconsistent "can't open site" errors in IE 6/7. I upgraded to the newest version of SWFobject API, which added a new set of bugs. Aside from the non-existent admin page, when I displayed multiple flash objects of the same type on a page the last one loaded would overwrite all earlier instances on the page.... plus all of my flash backgrounds magically turned white (apparently by design, but still annoying).

After much googling, and a little hacking, I fixed these problems (against version 1.1), although not in an ideal way.

Here's a page with the fixes in place:

http://www.wedrinkitblack.com/videos

Here are my changes to swfobject_api.module:

1. added a large random integer to everything that needs to be unique per instance.
2. wrapped the javascript in jquery's $(document).ready( function() {}); construct.

I don't have the tools to create a proper patch, so here's the whole function... sorry for the slop. All of my changes are in the theme function. Looking forward to a future release the fixes this stuff in the "right" way.


/*
 * Implementation of theme
 */
function theme_swfobject_api($url, $params){
//I added the "$unique" variable -- rand() may not work for everyone.  Insert your UID algorithm of choice.
  $unique = rand();
  $width = $params['width'] ? $params['width'] : "100%" ;
  $height = $params['height'] ? $params['height'] : "100%" ;
  $message = $params['no_flash'] ? $params['no_flash'] : t('You may need to click the headline to view multimedia content for this entry. Flash player required.<br /><br />');
  
  $name = str_replace(".swf", "", basename($url));
  
//Added the $unique marker to every name or ID that seemed to require uniqueness.
  $html  = "<div id='flashcontent_". $name . $unique . "'>$message</div>\n";

//Also started the document.ready construct to hold execution until the DOM is ready for changes.
  $html .= "<script>\$(document).ready( function() { var so$unique = new SWFObject('". $url . "', 'movie', '". $width ."','" . $height ."','" . $name . $unique ."'); \n"; 
  
  if ($params) {
    foreach ($params as $key => $value) {
      if (($key != "width") && ($key != "height") && ($key != "no_flash")) {
        $html .= " so$unique.addParam('$key', '$value'); \n";
      }
    }
  }
//Closed the document.ready at the end of the script... it's the extra });   
  $html .= "so$unique.write('flashcontent_". $name . $unique . "'); }); \n</script>";

 return $html;
} 
 

Comments

arthurf’s picture

Status: Active » Fixed

Thanks for the bug report. This was fixed in a recent release, so you should be good to go. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)