关于解决ExternalInterface不能在form中使用的方法

关于解决ExternalInterface不能在form中使用的方法

here is my workaround for the "movies inside of FORM tags dont work properly" bug. simply include the following javascript BEFORE the flash movies in the HTML.
<script type="text/javascript">
function ExternalInterfaceManager(){
this.registerMovie = function(movieName) {
 if(!window.fakeMovies)
  window.fakeMovies = new Array();
 window.fakeMovies[window.fakeMovies.length] = movieName;
}
this.initialize = function() {
 if(document.all){
  if(window.fakeMovies){
   for(i=0;i<window.fakeMovies.length;i++){
    window[window.fakeMovies[i]] = new Object();
   }
   window.onload = initializeExternalInterface;
   }
  }
 }
}
function initializeExternalInterface(){
 for(i=0;i<window.fakeMovies.length;i++){
  var movieName = window.fakeMovies[i];
  var fakeMovie = window[movieName];
  var realMovie = document.getElementById(movieName);
  for(var method in fakeMovie){
   realMovie[method] = function() {
   flashFunction = "<invoke name="" + method.toString() + "" returntype="javascript">" + __flash__argumentsToXML(arguments, 0) + "</invoke>";
   this.CallFunction(flashFunction);
   }
  }
  window[movieName] = realMovie;
 }
}
</script>
<script type="text/javascript">
 var eim = new ExternalInterfaceManager();
 eim.registerMovie("ShockwaveFlash1");
 eim.registerMovie("ShockwaveFlash2");
 eim.initialize();
</script>

Leave a Reply

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