1 Reply Latest reply on Apr 17, 2006 4:27 AM by llyfre

    firefox problems with actionScript

    llyfre
      Hello,

      I have a question concerning the way some javaScript is executed with the new flash 8 player using firefox as the browser. I have an all flash site and there is a button that is scripted to open a new browser window and then center it and load an html page into it with another flash file. What happens in firefox is that when the button is released, the new window opens down and to the right, entirely off of the monitor or just shy of off. In IE it opens in the upper left corner, then fills the monitor as designed.

      I'm not sure what exactly to post here as far as script goes, but here is the actionScript I use on the button in flash:

      on (release) {
      //customize the window that gets opened
      // 0 equals NO.
      // 1 equals YES.
      address = " http://www.unseenproductions.net/velvet.html";
      target_winName = "Velvet";
      width = 10;
      height = 10;
      toolbar = 0;
      location = 0;
      directories = 0;
      status = 0;
      menubar = 0;
      scrollbars = 1;
      resizable = 0;
      //sends data back to the function
      openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
      }

      In addition, there is a frame action which defines the function that is called upon to execute the javaScript which works together with the actionScript on the button:

      Movieclip.prototype.openWinCentre = function
      (url, winName, w, h, toolbar, location, directories, status, menubar, scrollbars, resizable)
      { getURL ("javascript:var myWin; if(!myWin || myWin.closed){myWin = window.open
      ('" + url + "','" + winName + "','" + "width=" + w + ",height=" + h + ",toolbar=" + toolbar + ",location=" + location + ",directories=" + directories + ",status=" + status + ",menubar=" + menubar + ",scrollbars=" + scrollbars + ",resizable=" + resizable + ",top='+((screen.height/1)-(" + h/1 + "))+',left='+((screen.width/1)-(" + w/1 + "))+'" + "')}else{myWin.focus();};void(0);");
      }

      If anyone could help me resolve this by providing a corrected version of this script that will work using firefox OR a new script that will allow me to open a customized window that is centered and works out of flash 8 in firefox, I would be most appreciative! Thanks in advance,

      Alexander
        • 1. Re: firefox problems with actionScript
          llyfre Level 1
          Here's what I found --In Flash 8 the code, which worked for Flash 6, does not work any more. Flash has introduced a new class, the ExternalInterface class. This class has several methods, one of which is call. Write this actionScript in the fla as a frame action over a button:

          "newWindow" is the argument holding your html file, which you want to open. You can define of course any height and width or position as you like.

          import flash.external.*;
          var newWindow:String;
          myBut.onPress = function () {
          newWindow = String (ExternalInterface.call ("openWindow", "javascript.html"));
          };


          Write this script in the header of your HTML page which encodes your swf:

          <SCRIPT language="javascript">
          <!--
          function openWindow(newWindow){
          window.open(newWindow, "myFile", "height=300, width=500, scrollbars=no, top=0");
          }
          -->
          </SCRIPT>

          This works great for firefox and safari, but not ie.5.2 for mac, don't know how well it works with the newer internet explorer for PC, my guess is just fine. Anyway, I was directed to this which exists at flashscript.biz.

          -Llyfre