2 Replies Latest reply on Apr 15, 2009 5:04 PM by SPGAnne

    dumb flashvars question

    SPGAnne Level 1

      This is probably more of a javascript question, but I'm hoping one of you gurus will have mercy on me and help out.  I want to set up a page with 2 links on it that launch the same .swf, but I want to pass a different flashvars parameter depending on which link they click on.  What is the most efficient way to do this.  I know I could have each link launch a different page that would have the flashvars parameter hard coded in it, but this seems to be kind of brute force, and I'm hoping there is a better way.  Thanks VERY much in advance for anyone willing to help.

        • 1. Re: dumb flashvars question
          RossRitchey Level 4

          Have the link call a javascript function (say loadSWF)


          <a href="" onclick="loadSwf('link1')">Link 1</a>

          <a href="" onclick="loadSwf('link2')">Link 2</a>


          Use SWFObject to embed the SWF in that function:


          function loadSWF(which){

               var flashvars = {};


               flashvars.varToPass = which;


               var params = {};

               var attributes = {};

               swfobject.embedSWF("myFlash.swf", "myDivToEmbedIn", "800", "600", "9.0.0", false, flashvars, params, attributes);



          You will need to have a div set up to load the SWF into.


          <div id="myDivToEmbedIn">


               <a href="http://www.adobe.com/go/getflashplayer">

                    <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />





          This example would pass the variable "varToPass" in, with the value "link1" or "link2" depending on which link was clicked.

          • 2. Re: dumb flashvars question
            SPGAnne Level 1

            Thanks so much for your willingness to help.  I had never used swfobject before, so did a pile of research on that today.  Downloaded from googlecode and such and used your helpful info.  I'm completely baffled though.  I've put the swfobject.js on my server, and tested that it worked using the swfobject test.swf sample that comes with it.  Then I removed test.swf from my server and put my own stuff there.  When I click on my link, I get an access forbidden message.  I have a password on this site, but I'm not getting prompted to enter my userid and pwd.  Also, I didn't get this when I was using the test html that came with swfobject.  I realize this is probably a swfobject question, but if you are willing to help, I would be VERY much obliged.