5 Replies Latest reply on Feb 18, 2010 9:57 AM by kglad

    Passing a variable into HTML to play a Flash file

    kenplaysviola Level 1

      I'm trying to create a simple SWF file that can receive the name of a FLV file in the HTML file and play it since I have many FLV files.  Basically using the technique of FlashVars.  I've set the contentPath/source in the components to be blank, and set my actions in the first frame to be player.source = filename, as was instructed to do so in a Flash book I am reading.  I then set the "filename" variable to a file in the same path as the web page in the HTML file, however, all I get is a blank Flash player skin.  The FLV file will not load.  I also tried setting the "filename" variable to load the FLV from a public website in the same domain and on another domain, but it still doesn't work.  Any ideas on what could be wrong?   I am using Adobe Flash CS 4.

        • 1. Re: Passing a variable into HTML to play a Flash file
          kglad Adobe Community Professional & MVP

          1.  you're probably not using flashvars correctly.  (if you're using standard embedding code there are 3 locations where you need to list your flashvars.)

           

          2.  you're posting in the as1/as2 forum and you're using as3 code.  for the flvplayback component:

           

          in as2, you assign the contentPath.  in as3, you assign the source.

          • 2. Re: Passing a variable into HTML to play a Flash file
            kenplaysviola Level 1

            1) You mention that there are 3 locations that need to reference FlashVars in my HTML file, but I made only 2.  Where should the 3rd change be made?  Below is my code:

             

            <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="640" height="480" id="flashvar" align="middle">
                <param name="allowScriptAccess" value="sameDomain" />
                <param name="allowFullScreen" value="false" />
                <param name="movie" value="flashvar.swf" />
                <param name="loop" value="false" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="#ffffff" />
                <param name="FlashVars" value="filename=file.flv" />
                <embed src="flashvar.swf" loop="false" quality="high" bgcolor="#ffffff" FlashVars="filename=file.flv" width="640" height="480" name="flashvar" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" />
                </object>

             

            The filename=file.flv is located in the same web directory as the flashvar.swf file.  Am I supposed to set the filename=www.mydomain.com/file.flv?  Or am I supposed to set the filename=c:\directory.\file.flv?

             

            2) I don't care if I'm using AS2 or AS3.  I just need this to work.  I thought I would post in AS2 since it would be more compatible with previous FlashPlayers.  And for the record, I am using contentPath.  My understanding is that the difference in this case would just be contentPath versus source.  My actionscript on the first frame is: player.contentPath = filename;

            • 3. Re: Passing a variable into HTML to play a Flash file
              kglad Adobe Community Professional & MVP

              1.  you need to add your flashvars to your ac_fl_runcontent() function.

               

              2.  there's a big difference between flashvars in as2 vs vs3.  but, you're good using as2 and contentPath directly on your main timeline.

              • 4. Re: Passing a variable into HTML to play a Flash file
                kenplaysviola Level 1

                You're a genius!  I got it to work once I added the FlashVars to the AC_FL_RUNCONTENT() function.

                 

                It looks like this (hope this helps others):

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

                ......................shortened for brevity.......................

                                'movie', 'flashvar',
                                'salign', '',
                                'FlashVars', 'filename=http://www.mydomain.com/file.flv'

                ); //end AC code

                 

                You get a star!