Jump to content

Get Dimensions Of Flash Movie


ecluley

Recommended Posts

hi, i am trying to use javascript to get the dimensions of a flash movie and i found a tutorial and script which does this. the only problem is that my flash movie resizes with the window but the javascript keeps returning the original dimensions- i assume it's simply getting the actual dimensions of the swf file but i need it to get the dimensions of the flash movie on screen. Is there a way of doing that? hope that makes sense and thanks in advance!here's my code:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /><title>index</title><script language="javascript">function getFlashObj(movie){   if (window.document[movie]) {	  return window.document[movie];   }   if (navigator.appName.indexOf("Microsoft Internet")==-1) {	  if (document.embeds && document.embeds[movie]) {		 return document.embeds[movie]; 	  }   } else {	  return document.getElementById(movie);   }}function getDimensions(movie) {   var movieObj = getFlashObj(movie);   var width = movieObj.TGetProperty("/", 8);   var height= movieObj.TGetProperty("/", 9);   alert("The current dimensions for the Flash Object ("+movie+") are "+width+" in width and "+height+" in height.");}</script></head><body bgcolor="#ffffff"><object id="detectme" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"><param name="movie" value="index.swf"><param name="quality" value="high"><param name="allowscriptaccess" value="samedomain"><embed src="index.swf" name="detectme" swliveconnect="true" width = "100%" height = "100%" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object><input type="button" onclick="getDimensions('detectme');"></body></html>

Link to comment
Share on other sites

wow, thanks so much for the quick reply and solution- it worked well!for some reason the width works perfectly but the height just always returns 16. not sure why but to be honest it doesn't matter as i can use math to work out the height anyways! cheersEwen

Link to comment
Share on other sites

hmmm, have been playing about with this all day and it looks like the offsetWidth is giving me an incorrect value, i.e. it is returning the width of the window and not of my flash movie. is there any way of just getting the width of the flash movie? basically what I am actually trying to do is make a page with a flash movie and then an iframe layed over the top of it. The flash movie will resize with the window (this works using the width=100% and height=100%) but what i need is to resize the iframe in the div layer and possition it so that it remains in proportion to the flash movie.does that make sense?thanks for the help so far and hope someone can advise me on a way to do this!thanksEwen

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...