views:

10

answers:

1

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"&gt;&lt;/script&gt; 
<!-- 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>
+1  A: 

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);
sberry2A
Thanks- that should probably solve it!
Yarin
Tip: You don't need to include the API key to use the Google ajax libs. I use it minus the API key every day. (Perhaps you only need the API key if you use the google.load method: http://code.google.com/apis/libraries/devguide.html#load_the_javascript_api_and_ajax_search_module ?)
pipwerks