SWFObject add-on: Size limiting for full window flash


[slug]swfforcesize[/slug]Here’s another add-on for SWFObject. This one allows you to create a full-window flash movie, but when the browser window is set below the specified size, the div containing the flash is kept at the minimum size and horizontal/vertical scrollbars are displayed.

Again it’s easy to implement, you have to make a few small changes to the HTML/CSS/JavaScript

Firstly, you have to remove the !DOCTYPE declaration from the very top of the HTML document, as, for some reason, this causes the browser to scroll, even though the flash container is set to 100% height. Then modify the CSS so the the html’s overflow is set to auto. Also, the #flashcontent div needs to have it’s positioning set to absolute, this stops Safari on Mac OS from showing the vertical scrollbar.
[css]
html {
height: 100%;
overflow: auto;
}

#flashcontent {
position: absolute;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
}
[/css]

In the javascript, do the following:
[js]
var so = new SWFObject(‘flash.swf’, ‘website’, ’100%’, ’100%’, ’8′, ‘#333333′);

so.useExpressInstall(‘js/expressinstall.swf’);

so.addParam(‘menu’, ‘false’);
so.addParam(‘scale’, ‘noscale’);
so.addParam(‘salign’, ‘lt’);

if( so.write(‘flashcontent’) )
{
var forcesize = new SWFForceSize( so, 900, 600 );
}
[/js]

When you call the ‘SWFForceSize’ constructor, the last two arguments are the minimum width and height of the movie, in this case the minimum size is 900×600 px.

Download SWFForceSize here.