Passing varibles to Flash via FlashVars

February 13th, 2008 . by polyGeek

I have to look this up all the time because I can never remember the syntax for using FlashVars in the various ways one embeds a SWF in an HTML file.

FlashVars is a way to pass data from the HTML containing page. You can read more about it here.

[ download example using AC_RunActiveContent and object/embed tags ]

For the <object><embed> tags

The <object> tag will run in IE. Add this param along with the others:

<param name=”FlashVars” value=”var1=One&var2=Two” />

The <embed> tag will run in Netscape/FireFox browsers. Simply place the following attribute anywhere inside the <embed> tag:

FlashVars="var1=One&var2=Two"

Using the Flash IDE’s Javascript ( AC_RunActiveContent.js )

I add the FlashVars parameter to the end of the AC_FL_RunContent function like so:
’salign’, ”, ‘flashvars’,'var1=One&var2=Two’); //end AC code

Don’t forget to add a comma after the - ’salign’, ”, - line. If you don’t you’ll get a Javascript error and nothing works. I’ve only made that mistake a few dozen times.

And don’t forget, you have to edit the <object><embed> tags contained in the <noscript> block manually.

Using swfobject

Check out the examples page at blog.deconcept.com here.

It’s pretty simple:

<script type=”text/javascript”>
var so = new SWFObject(”movie.swf”, “mymovie”, “400″, “200″, “8″, “#336699″);
so.addVariable(”var1″, “One”);
so.addVariable(”var2″, “Two”);
so.write(”flashcontent”);
</script>

Using Kimili Flash Embed Wordpress plugin

Use the fvars attribute:

[kml_flashembed movie="/flash/471_FlashVars.swf"height="100" width="200"

fvars="var1=One&var2=Two" /]
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Reddit
  • Slashdot
  • StumbleUpon
  • Technorati
  • Digg
  • Facebook

Leave a Reply

Name

Mail (never published)

Website

- Why ask? This confirms you are a human user!

   




© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites