views:

305

answers:

2

I have a full flash site which uses swfobject to embed it 100% height and width. I'm using swffit to force a browser scroll bar for pages with a large amount of content. This is all fine and works perfectly. I also have the content in HTML format, as alternative content and this also works apart from in order to get the flash swfobject to work I need to add the overflow = hidden in the CSS, like:

html{
height: 100%;
overflow:hidden; 
}
#content{
height: 100%;
}

This then stops the scroll bar showing when the alternative content is shown. Does anyone know how to fix this?

+2  A: 

I don't know SWFFit but why do you need the overflow: hidden in the first place? Won't it work without?

The only workaround that comes to mind is to define two classes, one with, one without overflow: hidden, and change the class of the html element programmatically from within Flash by triggering some Javascript.

Pekka
Yeah, I don't quite know why the overflow-hidden either. Maybe it's simply missing `margin: 0; padding: 0; height: 100%` on the `body`?
bobince
Thanks Pekka, I feel stupid. I couldnt remember why, but I was adamant that I needed the overflow hidden setting. But I didnt.
daidai
overflow:hidden fixes a scrollbar issue in IE6 for SWFs that are scaled to 100% height/width in the browser. probably 90% of the time you won't need it.
pipwerks
@pipwerks: good to know, thanks.
Pekka
+1  A: 

If you need to change a page's CSS or content based on the success of a SWFObject embed, use the callback function feature in SWFObject 2.2.

For dynamic publishing, it looks like this:

var flashvars = {};
var params = {};
var attributes = {};
var embedHandler = function (e){
};

swfobject.embedSWF("mymovie.swf", "targetID", "550", "400", "9.0.0", "expressInstall.swf", flashvars, params, attributes, embedHandler);

In your situation, if you needed to remove overflow:hidden from the HTML element, you could do this:

var flashvars = {};
var params = {};
var attributes = {};
var embedHandler = function (e){
   //If embed fails
   if(!e.success){
      document.getElementsByTagName("html")[0].style.overflow = "auto";
   }
};

swfobject.embedSWF("mymovie.swf", "targetID", "550", "400", "9.0.0", "expressInstall.swf", flashvars, params, attributes, embedHandler);

This callback function feature is only available in SWFObject 2.2.

pipwerks