Categories
Articles

FlashVars in Flash CS4

Publishing under Flash CS4 will provide the latest HTML wrapper with a boat load of Javascript. At one time a separate Javascript file was generated from the Flash IDE publishing. Now it is all in the HTML document.

The overall process is the same as it has been since first introduced. You need to publish the HTML one time and then turn it off as you need to edit the HTML document for your FlashVars. Dicing in the FlashVars for the new HTML wrapper appears as follows for the FlashVars variables message1 and name:

AC_FL_RunContent Javascript function arguments:

'movie', 'FlashVarsEx02','FlashVars', 'message1=Hello World&name=Alonzo (Lon) Hosford','salign', ''

Object tag for the no script possibility:

<param name="flashvars" value="message1=Hello World&name=Alonzo (Lon) Hosford" />

In Flash you extract the Flash vars as follows:

root.loaderInfo.parameters.name</p>
<pre><p>root.loaderInfo.parameters.message1</p>
<p>

An elegant way to dump all FlashVars

for (key in params)
{
	value = String(params[key]);
	trace ("\t" + key + "\t" + value );
}

Download completed FlashVars example for CS4 and Actionscript 3