1 Reply Latest reply on Sep 29, 2009 7:50 AM by Saransoft84

    Accessing FlashVars and passing them to a JavaScript function

    stevoad

      Hi,

       

      I'm working on a banner ad movie, which is loaded dynamically through ASP.Net. When I load the movie in the FlashVars I'm passing in 2 parameters, one a url and the other a mode.

       

      I then want to take these FlashVars and pass them to a JavaScript function which I'm calling through the Flash movie via a onPress event.

       

      Here's how my code currently looks:

       

      myButton.onPress = function()

      {

           trace("getURL");

           var href:String = _level0.href;

           getURL("javascript:CmsLinkToClick(href)");

      };

       

      And here's the html which loads the movie:

       

      <script type="text/javascript">

      //swfobject.registerObject("myFlashContent", "9.0.0");

       

          var flashvars = {

              mode: '2',

      href: 'http://www.google.com'

          };

       

      var params = { wmode: "transparent" };

          var attributes = { id: "slot1movie", name: "slot1movie" };

          swfobject.embedSWF("8489-SX_fin_refer_612x128.swf",

              "flashcontent1",

              "612",

              "118",

              "9.0.0",

              null,

              flashvars,

              params,

              attributes);

       

       

       

      function CmsLinkToClick( url )

      {

      alert( "CmsLinkToClick " + url);

      }

      </script>

      </head>

      <body>

      <div id="flashcontent1">

      </div>

      </body>

       

      I can get the JavaScript function "CmsLinkToClick" to work, but as soon as I try to access the FlashVar the JavaScript function fails.

       

      I have tried accessing the FlashVar using both _root.href and _level0.href, both break the JavaScript call.

       

      Is there a better way to do this or what is wrong with this and why can I not pass the FlashVars to the JavaScript function?

       

      Thanks

       

      Stephen