6 Replies Latest reply on May 4, 2009 11:32 AM by wkirklutz

    Control Flash with HTML (k)

    wkirklutz Level 1

      I've done this a long time ago and for the life of me cannot remember how(even found my old post here, where I said fscommand did the trick, but I never wrote exactly how I did it).


      I have two text links in HTML on my webpage. I have a small flash movie on the same page.


      I want to have the flash movie jump to a specific frame when one of these HTML text links is clicked. And to another frame when the other is clicked.


      I did it before with the fscommand, but I can't remember which project it was for so I can't look at my old code.


      It seems simple enough, but I really could use some sample HTML and ActionScript 2.0.



        • 1. Re: Control Flash with HTML (k)
          kglad Adobe Community Professional & MVP

          you can call a javascript function when your links are clicked and you can communicate from that js function to actionscript using the externalinterface class.

          • 2. Re: Control Flash with HTML (k)
            wkirklutz Level 1

            Is there somewhere I can see an example of this? HTML and ActionScript side?


            I do much better seeing other's code and adapting it to my needs than learning a new code.



            • 3. Re: Control Flash with HTML (k)
              kglad Adobe Community Professional & MVP

              yes, check the flash help files under the externalinterface class.  there's sample coding that shows communication from js to as (and back).


              use google to search for calling a js function when a link is clicked.

              • 4. Re: Control Flash with HTML (k)
                wkirklutz Level 1

                I've never used the ExternalInterface code before. The help is greek to me.


                I'm hoping to find a simple:

                1) Put THIS in your <a> tag in HTML

                2) Put THIS in your FLA file.





                • 5. Re: Control Flash with HTML (k)
                  wkirklutz Level 1

                  There is a behavior in my Dreamweaver entitled "Control Shockwave or Flash" that works very well if the SWF is embedded using Object Tags


                  Usually we embed using the generated code from Flash where it looks for AC_RunActiveContent.js and the version of the Flash Player.


                  This embedding method doesn't work with the "Control Shockwave or Flash" behavior, it might but I'm not sure how.


                  FLASH (check AC_RunActiveContent.js and version):


                    <script language="JavaScript" type="text/javascript">


                  var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);

                  if(hasRightVersion) {  // if we've detected an acceptable version

                  if (AC_FL_RunContent == 0) {

                  alert("This page requires AC_RunActiveContent.js. In Flash, run \"Apply Active Content Update\" in the Commands menu to copy AC_RunActiveContent.js to the HTML output folder.");

                  } else {

                  // embed the flash movie


                  'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0',

                  'width', '363',

                  'height', '227',

                  'id', 'PDA_YouTubeContest', <!-- My addition -->

                  'src', 'PDA_YouTubeContest',

                  'quality', 'high',

                  'pluginspage', 'http://www.macromedia.com/go/getflashplayer',

                  'align', 'middle',

                  'play', 'true',

                  'loop', 'true',

                  'scale', 'showall',

                  'wmode', 'opaque',

                  'devicefont', 'false',

                  'id', 'PDA_YouTubeContest',

                  'bgcolor', '#000000',

                  'name', 'PDA_YouTubeContest',

                  'menu', 'true',


                  'swliveconnect', 'true', <!-- My addition -->

                  'movie', 'PDA_YouTubeContest',

                  'salign', ''

                  ); //end AC code


                  } else {  // flash is too old or we can't detect the plugin

                  var alternateContent = 'Alternate HTML content should be placed here.'

                  + 'This content requires the Macromedia Flash Player.'

                  + '<a href=http://www.macromedia.com/go/getflash/>Get Flash</a>';

                  document.write(alternateContent);  // insert non-flash content


                  // -->



                      // Provide alternate content for browsers that do not support scripting

                      // or for those that have scripting disabled.

                      Alternate HTML content should be placed here. This content requires the Macromedia Flash Player.

                      <a href="http://www.macromedia.com/go/getflash/">Get Flash</a>




                  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" name="Object_PDA" width="363" height="227" id="Object_PDA" title="PDA_YouTube">

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

                      <param name="quality" value="high">

                      <embed src="PDA_YouTubeContest.swf" width="363" height="227" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="Object_PDA" swliveconnect="true"></embed>


                  • 6. Re: Control Flash with HTML (k)
                    wkirklutz Level 1

                    I figured it out!




                    I added this to the SCRIPT:


                    function MM_findObj(n, d) { //v4.01

                      var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {

                        d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}

                      if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];

                      for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);

                      if(!x && d.getElementById) x=d.getElementById(n); return x;



                    function MM_controlShockwave(objStr,x,cmdName,frameNum) { //v3.0

                      var obj=MM_findObj(objStr);

                      if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');



                    And this to the Flash generated HTML for embedding:

                    'id', 'PDA_YouTubeContest',
                    It works!