Uncaught ReferenceError: SWFObject is not defined

Insight picture Insight · Jul 16, 2011 · Viewed 20.2k times · Source

It sounds like a dumb question and FAQ as well, but I truly don't see any reason not to be able to run it.

I try to run a imagerotator with SWFObject and that's the error I get. I do include properly the swfobject.js file (accessible via the direct url) and I pass the parameters through an XML file which loads independently fine as well. I do use version 2.2.

Here there is my SWF call:

<div id="slide1"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this rotator.</div>
                    <div id="rotator"></div>
                    <script type="text/javascript">


                        var s1 = new SWFObject("/admin/cms/imagerotator.swf","rotator","606","199","5");
                        s1.addVariable("file","imagerotator.php");

                        s1.addParam("allowfullscreen","false");
                        s1.addVariable("linkfromdisplay", "false");
                        s1.addVariable("transition","lines");//bgfade,blocks,bubbles,circles,fade,flash,fluids,lines,random,slowfade
                        s1.addVariable("rotatetime","5");
                        s1.addVariable("overstretch","false");
                        s1.addVariable("backcolor","0xFFFFFF");// change if its helps to fit better in design (optional)
                        s1.addVariable("shuffle","false");
                        s1.addParam("wmode", "transparent");
                        s1.addVariable("showicons","false");
                        s1.addVariable("shownavigation","false");
                        s1.write("slide1");

                    </script>

I doubt that this usage of the SWFobject is completely inappropriate for this version, although I use a sample code of a CMS including this exact version of the library.

Answer

Kris picture Kris · Jul 17, 2011

The implementation changed:

1) Your problem is described (and solved) here.

2) Check the original docs here.

Basically you need to use swfobject.embedSWF(...) now instead of var x = new swfobject(...)

In any case, Google is your friend on this one ;)