Passing Variables into Flash using FlashVars
Sep.26, 2009 in
Actionscript, HTML, Javascript, PHP, Programming
The trouble with Flash has always been the level of communication between Flash and the web page. While this isn’t a new topic, it’s one that many webmasters have a lot of issues with. This is written assuming someone already knows how their way around Flash or actionscript. Looking at the standard Flash embed code:
In order for this to work, you need a copy of AC_RunActiveContent.js. It's literally everywhere on the Internet. Just Google it and take your pick.
In order for this code to work, the settings must be configured to work with your Flash swf. The above code will pass 2 variables, var1=$1 and var2=$2, using FlashVars. Your Flash code in actionscript can then be configured to read the variables within the Flash file using _root.var1 and _root.var2. What you choose to do with the information that gets passed is now up to you. For more information on how to use AC_RunActiveContent, visit the Adobe Knowledgebase.
| Javascript | | copy code | | ? |
| 01 | |
| 02 | <script type="text/javascript"> |
| 03 | AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','100','height','100', 'wmode', 'transparent', 'bgcolor', '#000000','src','flashfile','FlashVars','var1=1&var2=','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','flashfile' ); //end AC code |
| 04 | </script> |
| 05 | <noscript> |
| 06 | <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="100" height="100"> |
| 07 | <param name="movie" value="flashfile.swf"> |
| 08 | <param name="quality" value="high"> |
| 09 | <param name="FlashVars" value="var1=1&var2="> |
| 10 | <embed src="flashfile.swf" FlashVars="var1=1&var2=" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="640" height="680"></embed> |
| 11 | </object> |
| 12 | </noscript> |
| 13 |
In order for this to work, you need a copy of AC_RunActiveContent.js. It's literally everywhere on the Internet. Just Google it and take your pick.
In order for this code to work, the settings must be configured to work with your Flash swf. The above code will pass 2 variables, var1=$1 and var2=$2, using FlashVars. Your Flash code in actionscript can then be configured to read the variables within the Flash file using _root.var1 and _root.var2. What you choose to do with the information that gets passed is now up to you. For more information on how to use AC_RunActiveContent, visit the Adobe Knowledgebase.



















































Leave a Reply