Question

Locked

detect flash size with javascript

By coolaid09 ·
Hello, I am trying to dynamically detect the size of flash being loaded into a window, and then write out the javascript embed tags so that they include the detected height and width. The page I have does not have a body tag - it's being pulled into another html page. The flash file is chosen by a user, via a form.

In the "header" area, I have:

<script type="text/javascript">
function getDimensions(movie) {
var movieObj = getFlashObj(movie);
var width = movieObj.TGetProperty("/", ;
var height= movieObj.TGetProperty("/", 9);
alert("The current dimensions for the Flash Object ("+movie+") are "+width+" in width and "+height+" in height.");
return height;
return width;
}
</script>

Then, in the area where flash is embeded:

<script type="text/javascript">
document.write('<object id="detectme" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" align="top">');
document.write('<param name="movie" value="]]><IMAGE variable goes here><![CDATA[">');
document.write('<param name="wmode" value="transparent">');
document.write('<param name="quality" value="high">');
document.write('<param name="SCALE" value="noborder">');
document.write('<param name="allowscriptaccess" value="samedomain">');
document.write('<embed src="]]><IMAGE variable goes here><![CDATA[" name="detectme" swliveconnect="true" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" scale="noborder" align="l"></embed>');
document.write('</object>');
</script>

<!--this next line for testing purposes-->
<a href="javascript:getDimensions('detectme');">Click Here For Dimension Information</a>

I've tried writing out the 'height' and 'width' variables in the embed javascript and that didn't work. I've also tried trying to write out the width and height variable names with document.write and put:
<script type="text/javascript">
window.onload = function (evt) {
getDimensions('detectme');
document.write(width);
document.write(height);
};
under where the flash would be embeded, but that didn't work either. (JavaScript error says 'width is undefined.')

When I try putting:
window.onload = function (evt) {
function getFlashObj(movie);
getDimensions('detectme');
};
in the header, I get the 'object expected' error.

Is there soemthing else I should be/shouldn't be trying?

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Web Development Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums