5 Replies Latest reply on Mar 12, 2012 4:57 AM by federatedfilmsuk

    Calling JavaScript from a swf in wordpress

    federatedfilmsuk

      Just started using wordpress for my site after years of standard HTML and hit a problemwith an old Flash file I've usedfor 10 years

      So I have a flash 6 swf file living in my media directory at

      http://www.wealthcoachinguk.com/wp-content/uploads/2012/03/wol.swf

      and the swf file wants to call a JavaScript function on my HTML page living at

      http://www.wealthcoachinguk.com/?page_id=4

      Now on my old non-wordpress web site I just put the html and swf file in the same directory and this call always worked

      javascript:top.fSendForm()

      But now the swf file is in another location I don't know how to reference my JavaScript function.

      Not done JavaScript for over 10 years so would appreciate any help with this!

      thx

      Kevin

        • 1. Re: Calling JavaScript from a swf in wordpress
          Ned Murphy Adobe Community Professional & MVP

          I can only guess that in the old version of things your html file embeds the swf file in it so that the swf can communicate with the page that loads it.  That would still have to be the case as I do not know of any way an swf can just communicate with any file on the server.  So whatever page your swf is currently in should have that same javascript functionality coded into it.  If it doesn't, then you should at least try it as a first attempt.

           

          An swf can communicate with the html page that holds it using the ExternalInterface class, but I believe that class didn't come into being until Flash 8.  If you can edit your file and save it as a Flash 8 or newer file, then you can make use of this class.  If you have a newer version of Flash than Flash 6, what you should do is search Google using terms like "AS2 ExternalInterface" and you should find a tutorial or two on putting it to use.

           

          If you don't have a newer version of Flash you can always download a trial version of the latest (assuming your hardware can handle it) and use it for a 30 day trial period.

          • 2. Re: Calling JavaScript from a swf in wordpress
            federatedfilmsuk Level 1

            Thx Ned for you help. What I am trying to do is call a JavaScript routine that then populates an invisble form with data from the swf which then calls a CGI Formmail script on the server. There may well be a beter way to do this in CS5?


            HTML code is

             

            <HTML><HEAD>

             

             

            <TITLE>Life Cycle v3</TITLE>

            <script language="JavaScript">

            <!--

                // Copyright: Multimedia Creations Ltd., UK

                // Email: info@mmcr.co.uk

                function fSendForm(n,t,o,p,m,d){

                    var myForm = document.frmContact;

                    myForm.subject.value = "Life Cycle Results for " + n;

                    myForm.name.value = n;

                    myForm.email.value = t;

                    myForm.comments.value = o;

                    myForm.recipient.value = "kevin.h.boyd@gmail.com";

                    myForm.redirect.value = "http://www.wealthcoachinguk.com/";

                    myForm.wheelData.value = d;

                    myForm.submit();

                }

            // -->

            </script>

            </head>

             

             

            <BODY bgcolor="#FFFFFF" link="#FFFFFF" vlink="#FFFFFF" alink="#FFCC00" text="#FF6666">

                 <p><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="500" height="500">

                      <param name=movie value="LC0026.swf">

                      <param name=quality value=high>

                      <embed src="LC0026.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="500" height="500">

                      </embed>

                    </object>

                 </p>

             

                 <p><font face="Verdana, Arial, Helvetica, sans-serif" color="#0000FF" size="2">If

                    nothing appears above then <a href="http://www.macromedia.com/go/getflashplayer/" target="_blank"><font color="#0033FF">click

                    here</font></a></font>

                 </p>

                      <!-- Replace the URL below with your servers address for the formail CGI script -->

                      <form name="frmContact" method="post" action="http://cgi-pub.freezone.co.uk/cgi-bin/formmail.pl">

                      <input type="hidden" name="subject">

                      <input type="hidden" name="name">

                      <input type="hidden" name="email">

                      <input type="hidden" name="comments">

                      <input type="hidden" name="recipient">

                      <input type="hidden" name="redirect">

                      <input type="hidden" name="wheelData">

                      </form>

             

             

            </BODY>

            </HTML>

            • 3. Re: Calling JavaScript from a swf in wordpress
              Ned Murphy Adobe Community Professional & MVP

              What is keeping you from just having the Flash file deal with sending the data to the CGI file rather than having the html/javascript as a middleman?  You should look into taking this approach... try searching Google using terms like "Flash to CGI".

              • 4. Re: Calling JavaScript from a swf in wordpress
                federatedfilmsuk Level 1

                Hi Ned,

                 

                I did do a search for Flash to CGI and it seems to involve using loadVariables to call a CGI script but as my cgi library uses the domain name of my hosting service and the flash docs say I can only call a CGI script if it shares the same domain as my web page (which is of course different to my hosting service)

                 

                Most confused! Maybe I need to hire someone to fix this for me!

                 

                Kevin

                • 5. Re: Calling JavaScript from a swf in wordpress
                  federatedfilmsuk Level 1

                  Could anyone recomend a good web site to find a Flash developer that would know how to call the CGI Formmail script?