Search code examples
flashapiembedswfobject

SWFObject not working from Google Libraries API?


The following embed code works fine when I load swfobject.js locally. However, when I try to load the swfobject.js from Google Library APIs, the Flash movie fails to load. I know I'm using a valid key, and the swfobject.js file is definetely being loaded, but I get an "Uncaught ReferenceError: SWFObject is not defined (anonymous function)"

Any ideas?

<body> 

<!-- DOESN'T WORK -->
<script type="text/javascript" src="http://www.google.com/jsapi?key=(VALID KEY)"></script>
<script src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> 
<!-- WORKS -->
<!--script type="text/javascript" src="swfobject.js"></script-->

<div id="flashcontent">
  This text is replaced by the Flash movie.
</div>

<script type="text/javascript">
   var so = new SWFObject("mySwf.swf", "mymovie", "400", "200", "8", "#336699");
   so.write("flashcontent");
</script>


</body>

Solution

  • v2.2 does not use the old 1.x api.

    Try something like this.

    var flashvars = { };
    var params = { wmode:'opaque' };
    var attributes = { name:"mymovie" };
    swfobject.embedSWF("mySwf.swf", "flashcontent", "400", "200", "8.0.0","expressInstall.swf", flashvars, params, attributes);