...

View Full Version : Swfobject 2 - center flash content problem



CaptainB
03-15-2009, 02:23 PM
Hi guys,

Until resently I used SWFObject 1.5 to display my flash. It worked good, but I decided to try to upgrade to 2.0. But now my flash banner is not centered within the div as it used to be but floats to the left. The banner is rendered to the div "header":


<script type="text/javascript" src="javascript/simplemarquee.js"></script>
<script type="text/javascript">
var params = {};
params.wmode = "transparent";
swfobject.embedSWF("flash/headermov.swf", "header", "900", "200", "9.0.0", "flash/expressinstall.swf", params);
</script>

CSS:

#header { margin:0px auto;
width:900px;
height:200px;
text-align:center;
line-height:200px;
}

I tried to add the 'align' param, but that didn't seem to have any effect. Does anybody know how to solve this?

abduraooft
03-15-2009, 03:57 PM
Does anybody know how to solve this? Can we have a link?

_Aerospace_Eng_
03-15-2009, 04:35 PM
<script type="text/javascript">
var params = {};
params.wmode = "transparent";
var attributes = {};
attributes.style = 'display:block;margin:auto;';
swfobject.embedSWF("flash/headermov.swf", "header", "900", "200", "9.0.0", "flash/expressinstall.swf", params);
</script>

CaptainB
03-15-2009, 04:57 PM
Aero,
It does not work. Even if I add an 'attributes':

<script type="text/javascript">
var params = {};
params.wmode = "transparent";
var attributes = {};
attributes.style = 'display:block;margin:auto;';
swfobject.embedSWF("flash/headermov.swf", "header", "900", "200", "9.0.0", "flash/expressinstall.swf", params, attributes);
</script>

Abdura,
It's still on localhost, but here's a screen so you can see what I mean. The banner is slightly pushed to the left instead of being centered:

_Aerospace_Eng_
03-15-2009, 07:36 PM
What exactly are you trying to center? Your #header CSS has a width of 900px and a height of 200px. Your flash has the same dimensions. Post the rest of your code as its likely you have more of it.

CaptainB
03-16-2009, 09:07 AM
Doh. I had messed up the divs so that the header div was outside the main container. Fixed now, thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum