Have you noticed that since the last round of browsers came out earlier this year your JavaScript functions can no longer call ActionScript in your Flash applications? If you’re like most people, you were probably using Adobe’s sample function to grab your Flash document in the DOM. Unfortunately, the latest couple Firefoxs and the latest Internet Explorer both decided to change what type of object they returned in regards to embedded objects, which requires a function that’s a bit more complex. Here’s what I threw together quickly a while ago. There’s probably a more elegant solution if you want to put some time into it, but this code will work if you want to use it:

function getInternetExplorerVersion()
	// Returns the version of Windows Internet Explorer or a -1
	// (indicating the use of another browser).
	{
	   var rv = -1; // Return value assumes failure.
	   if (navigator.appName == 'Microsoft Internet Explorer')
	   {
	      var ua = navigator.userAgent;
	      var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
	      if (re.exec(ua) != null)
	         rv = parseFloat( RegExp.$1 );
	   }
	   return rv;
	}
function getFlashMovie(movieName) {
	  if (navigator.appName.indexOf("Microsoft") != -1) {
		  var ver = getInternetExplorerVersion();
		  if (ver > 8 ) {
			  return window[movieName][0];
		  } else {
		    	return window[movieName];
		  }
	  } else {
	        if(document[movieName].length != undefined){
	             return document[movieName][1];
	        }
	    return document[movieName];
	  }
}
Tagged with:
 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Switch to our mobile site