1 Reply Latest reply on Aug 19, 2009 1:19 PM by Jason Lampitt

    CS4: ExternalInterface & FireFox v3.013 (yeah, again...)

    Jason Lampitt

      I've spent about a day on this... Publishing a swf for AS3/FP9, following the example in the ActionScript 3 documentation to get two-way communication between a SWF and javascript. Works great in IE.

       

      I've sifted through what seems like a million posts on the subject, with people getting the same result... the function I/they are attempting to call doesn't exist.

       

      In the documentation example, there's a function to find/return either the SWF as an object or embed tag depending on which browser you're viewing the page in.

       

       

      function thisMovie(movieName) {
           if (navigator.appName.indexOf("Microsoft") != -1) {
               return window[movieName];
           } else {
               return document[movieName];
           }
      }

       

       

      The core issue seems to be that in Firefox v3.013, "return document[movieName];" returns an array of objects.  Specifically:

       

      [object#ExternalInterfaceExample, embed]

       

       

      By simply telling the function to return the second item in the array (return document[movieName][1];) everything works consistantly, as expected.

       

       


      I'm wary though, and wondering:

      1. Why Firefox is acknowledging the <object> tag ('cause I thought it ignored it?)
      2. What potential pitfalls await me by going this route?
        • 1. Re: CS4: ExternalInterface & FireFox v3.013 (yeah, again...)
          Jason Lampitt Level 1

          Well, after some lunch and going through things with a fine-tooth comb, I figured out what the problem is.

           

          In Dreamweaver, I had selected the SWF and changed the value in the id/name field in the properties palette which inadvertently ADDED a name attribute to the <object> tag.

           

          The name attribute on the <object> tag was the reason Firefox was returning two objects. I simply deleted the name attribute on the <object> tag and everything worked as expected.

           

          ------------------------------------------------------------------------------------------ -------------


          In case you're curious, the reason I changed the id/name field is because I'm creating Dreamweaver templates for other, non-technical individuals, to use. Part of the template is the SWF content on the page which must always have the same id/name regardless of the content. Individuals using these templates will only be required to change the source SWF and nothing more.