homepage Welcome to WebmasterWorld Guest from 54.226.213.228
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
Resize Flash Object
Robert Poole




msg:3654511
 2:04 pm on May 20, 2008 (gmt 0)

Hey there.

I'm trying to resize a flash object with some javascript.

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.

[edited by: jatar_k at 5:22 pm (utc) on May 21, 2008]
[edit reason] no urls thanks [/edit]

 

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved