Search code examples
flashflash-cs4flashvars

Pass variables into a Flash movie from HTML


As a Flash newbie I found this very confusing and it cost me a couple of hours. Answering my own question here in case anyone has the same problem.

Technically you should be able to do something like this:

<param name="movie" value="movie.swf?param=value" />
<embed src="movie.swf?param=value" ...

Or this:

<PARAM NAME "FlashVars" VALUE="param=value">
<EMBED .... FlashVars="param=value">

Both should create a variable in the _root or _level0 scope called 'param' with the correct value.

These are documented here

However, in my particular version of Flash (CS4, ActionScript 2.0), this didn't work.


Solution

  • The answer which worked for me is to modify the AC_FL_RunContent() function in the HTML generated by CS4, adding the parameters which need to be passed to the movie, e.g.

    'flashvars', 'param=value',
    

    It seems this function overwrites anything which is directly specified in the OBJECT and EMBED tags or on the query string.

    There may be better solutions out there...