Example 1 - as a parameter
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="200" height="400" id="myflash"> <param name="movie" value="mymovie.swf" /> <param name="FlashVars" value="name1=value1&name2=value2" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <embed src="mymovie.swf" FlashVars="name1=value1&name2=value2" quality="high" bgcolor="#000000" width="200" height="200" name="myflash" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /> </object>
Example 2 - appended to the filename
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.adobe.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="200" height="400" id="myflash"> <param name="movie" value="mymovie.swf?name1=value1&name2=value2" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <embed src="mymovie.swf?name1=value1&name2=value2" quality="high" bgcolor="#000000" width="200" height="200" name="myflash" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" /> </object>
Note that in both these examples the variables are declared twice, once in a param tag and once in the embed tag. This is because different browsers use different parts of the object tag. Internet Explorer reads the object and param tags, whilst Netscape compatible browsers read the embed tag.
Using these variables in your actionscript code is done slightly differently depending on the version of actionscript you are using. In AS1 and AS2, using FlashVars is very simple. The variables are all made available within the root scope of your movie, and so are accessed like this:
trace(_root.name1); //outputs: value1
or, if you prefer:
trace(_level0.name1); //outputs: value1
In AS3, things are done slightly differently. The FlashVars are now stored as part of the loaderInfo object, and are accessed like this:
trace(root.loaderInfo.parameters.name1); //outputs: value1
That's all for FlashVars, have fun with them!






MultiQuote



|