Well, I finally figured it out. I wanted to shrink a flash to fit the container div with SWFObject, even if I didn't know the width of the container div.
Put in header
Code:
<script type="text/javascript" src="js/swfobject.js"></script>
of course have the SWFobject installed.
Change body tag to
Code:
<body onResize="document.location.href = document.location.href">
Code:
$header = "swf/example.swf";
$headerDims = getimagesize($header);
$headerWidth = $headerDims[0];
$headerHeight = $headerDims[1];?>
<script type="text/javascript">
onResize="document.location.href = document.location.href"
if ("<?php echo $header;?>" != ""){
dwidth = document.getElementById('center').offsetWidth;
var width = <?php echo $headerWidth;?>;
var height = <?php echo $headerHeight;?>;
if (width > height) {
var percentage = (dwidth / width);
}
else {
var percentage = (dwidth / height);
}
}
</script>
<div id="flashcontent">
Dummy text to fill in for now, like alt text for the .swf in case it doesn't load.
</div>
<script type="text/javascript">
var width = Math.floor(width * percentage);
var height = Math.floor(height * percentage);
var so = new SWFObject("<?php echo $header;?>", "mymovie",width,height, "6", "#fff");
so.write("flashcontent");
</script>
Now it automatically resizes when the window is resized and everything! Great for those who want to fit flash into a liquid design.
Bookmarks