2 Replies Latest reply: Sep 18, 2009 5:29 PM by DavidSalahi RSS

    Can't Use Dreamweaver Flash Embedding with ExternalInterface

    DavidSalahi Community Member

      I've been trying to use ExtermalInterface to call ActionScript 3 functions from JavaScript and have been having a problem when embedding SWF files using Dreamweaver. When I use the sample code at the bottom of the ExternalInterface docs page (http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/external/ExternalInterface.html) the JavaScript/ActionScript function calls work fine. But when I insert a SWF with Dreamweaver CS4 they don't. They do actually work in Internet Explorer 8 but not in Firefox 3.5, Safari 4, or Chrome 3.

       

      The problem has to do with the the way the SWF embedding is done. On the ExternalInterface page mentioned above a different form of the <object/embed> tags is used than in DW. Here's the sample code from the docs page:

       

           <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                   id="ExternalInterfaceExample" width="500" height="375"
                   codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
               <param name="movie" value="ExternalInterfaceExample.swf" />
               <param name="quality" value="high" />
               <param name="bgcolor" value="#869ca7" />
               <param name="allowScriptAccess" value="sameDomain" />
               <embed src="ExternalInterfaceExample.swf" quality="high" bgcolor="#869ca7"
                   width="500" height="375" name="ExternalInterfaceExample" align="middle"
                   play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
                   type="application/x-shockwave-flash"
                   pluginspage="http://www.macromedia.com/go/getflashplayer">
               </embed>
           </object>

       

      In DW, instead of an <embed> tag a second object tag is inserted. I did find that by manually giving the second <object> tag its own ID (a different ID from the one given the first tag by DW I could make the function call work in FF. But you would then have to choose the ID based on the browser. And, worse, that technique doesn't work in Chrome or Safari.

       

      So, the workaround seems to be to use the style of embedding used on the ExternalInterface page. But, I don't like that approach for several reasons. First, the page  won't tell the user they need to upgrade their FlashPlayer if that's a problem. Second, you have to manually copy/past the embedding code instead of using DW's nice menu option. And I suspect there may be other benefits to the DW approach,

       

      So, is there a way to make the DW embedding style work with ExternalInterface in all the major browsers??

       

      David Salahi

        • 1. Re: Can't Use Dreamweaver Flash Embedding with ExternalInterface
          Ned Murphy CommunityMVP

          I don't have anything to offer in favor of using DW to embed Flash content and I avoid using it to embed Flash content as a rule.  For whatever reason DW invented their own way which isn't consistent across the product line and I have seen it be troublesome in other circumstances besides what you are facing.  I always let Flash generate an html file when I publish an swf and then copy the embedding code from that into whatever html page it is bound for.

          • 2. Re: Can't Use Dreamweaver Flash Embedding with ExternalInterface
            DavidSalahi Community Member

            Very interesting, thanks for your insight. Dreamweaver does seem to be a black sheep in this regard. Curiously, one of the reasons I wanted to stick with DW is because it highlights the <embed> tag in yellow—which normally means an HTML error. Not being entirely up on the ins and outs of the embed tag I thought maybe it's deprecated or something so wanted to avoid it. But now, I've found that it's apparently the right way to do things.

             

            I did a little testing; here are my results...

             

            My SWF was originally generated in FlexBuilder (as an ActionScript project) so I copied over the Flex-generated HTML page and modified it for use with ExternalInterface. That works fine in all four of the browsers I mentioned in my original post.

             

            Next, I grabbed an HTML page generated by Flash's Publish menu option and made the same modifications. Again, everything was copacetic.

             

            Each of the three tools (Flash, Flex & Dreamweaver) generate different HTML code for embedding a SWF file and only two of them work with ExternalInterface. I guess I'll steer clear of Dreamweaver's Insert-> Media -> SWF menu option in the future. This cost me an entire day of hair-pulling.

             

             

            But thanks for your tip!

             

            David Salahi