Jump to content
Sign in to follow this  
ecluley

Get Dimensions Of Flash Movie

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>

Share this post


Link to post
Share on other sites

Probably the offsetWidth and offsetHeight will return the dimensions you're looking for.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

The problem is that when you assign 100% width to the flash movie, you are making it the size of the window.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...