Hey there.
I’m trying to resize a flash object with some javascript, similar to the way it’s done on this site: [url]http://filippasmedhagensund.com/
Basically I’ve got a massive background slideshow which I want to resize according to the window size, but without the white space, so if the window is tall and skinny the flash will be 100% in height with the sides overflowing off the screen, and if the window is short an fat have the flash 100% width with the top and bottom of the flash not shown.
I think where I’m going wrong is with the getAttribute / setAttribute but this is basically my first go with javascript so it could be riddled with errors. All I’ve done successfully so far is figure out the desired new height and new width for my flash element so I know that part works but the rest pretty much doesn’t. Anyway, here it is:
magicRatioNumber = document.body.clientWidth / document.body.clientHeight;
var flash = document.getElementById(“hayden”);
if (magicRatioNumber >= 1.25) // Width needs to be 100%
{
// Calculate new height
newHeight = Math.round(document.body.clientWidth * 1.25);
newWidth = document.body.clientWidth;
flash.setAttribute(“width”,”newWidth”);
flash.setAttribute(“height”,”newHeight”);
document.write(newWidth + ” x ” + newHeight);
}
else // Height needs to be 100%
{
// Calculate new width
newWidth = Math.round(ocument.body.clientWidth * 0.8);
newHeight = document.body.clientHeight;
flash.setAttribute(“width”,”newWidth”);
flash.setAttribute(“height”,”newHeight”);
document.write(newWidth + ” x ” + newHeight);
}
hayden is the name/id for my example flash movie.
Any help/suggestions would be appreciated.