PDA

View Full Version : JS SWFObject not working



zakoue
January 14th, 2010, 05:06 AM
Hey,

For some reason I can't get SWFObject to work. I'm using the following script:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

</head>

<body>

<div id="flashcontent" />

<script type="text/javascript" src="js/swfobject.js" />
<script type="text/javascript">

var so = new SWFObject("Index.swf", "flashmovie", "498", "2300", "8", "#ffffff");
so.addParam("wmode", "opaque");
so.addParam("base", ".");
so.addVariable("xmlpath", "content.xml");
so.write("flashcontent");
</script>

</body>

</html>

Can anyone spot where the problem is?
Thanks!!

a tadster
January 15th, 2010, 07:06 PM
i think you need to close your div as follows:


<div id="flashcontent"></div>
and
if your using swf object 2.2 (which you should)
use it like this:


<script type="text/javascript" src="js/swfobject.js" />
<!-- also be sure swfobject.js is in a folder named js which is in your main folder -->
<script type="text/javascript">
//<![CDATA[
var flashvars = {};
var params = {};
var attributes = {};
function overcomeIE(forthis, itsok, tobeclass){

forthis["class"] = tobeclass;
forthis["id"] = itsok;

}
params.menu = "true";
params.quality = "high";
params.wmode = "opaque";
params.swfliveconnect = "true";
params.allowscriptacces = "Always";
params.allowfullscreen = "true";
params.bgcolor = "#ffffff";
params.flashvars = "xmlpath=content.xml";
overcomeIE(attributes, "flashmovie", "aCssClassIfYouWant");

swfobject.embedSWF("Index.swf",
"flashcontent", "498", "2300",
"8.0.0", false, flashvars, params, attributes);
//]]>
</script>
</body>
</html>
oh, and is the height of your swf going to be 2300? or is that supposed to be the width?
Either way, that is rather large, if possible you should not do that, if you want your swf to fill the page use 100% for width or height or both.

Edit: added overcomeIE function for id and class.