2 Replies Latest reply on Jul 31, 2008 8:44 AM by macdeke

    ExternalInterface.call across domains?

    macdeke
      I'm using ExternalInterface.call in a swf file to call a javascript in the html container. The swf file is located in a different domain than the html container. Everything works fine if all files are within the same root directory, but as soon as I reference the swf file located in the other domain, the call stops working! What am I missing?

      swf file has this in frame 1:
      import flash.external.ExternalInterface;
      function clickListener(eventObj:Object):Void {
      ExternalInterface.call("sendToResponseForm");
      }

      swf file has this on mc instance tracked as button:
      on(press){
      clickListener();
      }

      html file/container has this in <head> tag:
      <script type="text/javascript">
      function sendToResponseForm(){
      window.location = "my.other.html.file";
      }
      </script>

      html file has this embedded:
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=" http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="700" height="550">
      <param name="movie" value=" http://www.otherdomain.com/vid/my.SWFFile.swf" />
      <param name="quality" value="high" />
      <embed src=" http://www.otherdomain.com/vid/my.SWFFile.swf" quality="high" pluginspage=" http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="700" height="550"></embed>
      </object>

      Hopefully, that's enough for you to chew on. Like I said if swf and html are in the same domain, it works. Just as soon as I point to second domain for swf file source it stops working.

      thanks
      deke
        • 1. Re: ExternalInterface.call across domains?
          macdeke Level 1
          Anybody have any ideas?
          • 2. Re: ExternalInterface.call across domains?
            macdeke Level 1
            Here's my mistake -- the swf file was fine and actually worked in IE6/IE7 but wouldn't work in Firefox. The process of including the swf file in the HTML was flawed. I originally published the HTML using Dreamweaver to write the <object> in the code. What fixed the problem was I published the swf file using Flash to a desktop folder which produced a javascript file (AC_RunActiveContent.js), the swf file and the HTML. The javascript dynamically determines which browser was being used and which player plugin was required. The script ultimately loads/writes the embed or object for the swf file appropriately for the content environment and everything communicates properly. It didn't have anything to do with cross domain communication at all.

            The main challenge was updating the Flash HTML/Javascript to use the proper swf resource which was located on a different server and move the js file to the appropriate directory updating the link in the HTML accordingly. My only concern was the added overhead of an external javascript source. But, at least I'm not concerned with whether it works or not anymore.

            Hope this helps somebody.

            deke