3 Replies Latest reply on Aug 28, 2007 1:15 PM by Newsgroup_User

    Javascript Help (k)

    Level 7
      Not sure why this isn't working.

      I have a Flash movie in an HTML document. I have a layer in the HTML
      document called "textLayer" I have a button in the HTML document, with
      the following code:
      <p>Make it <a href="#"
      onClick="MM_callJS('opacity(\'textLayer\',0,100,2000)')">Fade In
      </a></p>

      This calls a Javascript function:
      function opacity(id, opacStart, opacEnd, millisec) {
      //speed for each frame
      var speed = Math.round(millisec / 100);
      var timer = 0;

      //determine the direction for the blending, if start and end are
      the same nothing happens
      if(opacStart > opacEnd) {
      for(i = opacStart; i >= opacEnd; i--) {
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer *
      speed));
      timer++;
      }
      } else if(opacStart < opacEnd) {
      for(i = opacStart; i <= opacEnd; i++)
      {
      setTimeout("changeOpac(" + i + ",'" + id + "')",(timer *
      speed));
      timer++;
      }
      }
      }

      //change the opacity for different browsers
      function changeOpac(opacity, id) {
      var object = document.getElementById(id).style;
      object.opacity = (opacity / 100);
      object.MozOpacity = (opacity / 100);
      object.KhtmlOpacity = (opacity / 100);
      object.filter = "alpha(opacity=" + opacity + ")";
      }


      The HTML button works.

      However, I cannot for the life of me get a button in Flash to trigger
      the Javascript. Here is the ActionScript for the button:

      on (release) {
      getURL("javascript:MM_callJS('opacity(\'textLayer\',0,100,2000)')");
      }


      Here is the URL for this:
      http://www.redheadcompanies.com/CLIENTS/TaiSophia/2007_TaiSophia/Website_Phase_I/taiDesign .html

      Blue Box at the top is the Flash button the text at the bottom is the
      HTML button.

      -Kirk