Subscribe to RSS
get email updates
home | about | pixDif AIR app | video tutorials
polyGeek.com

place your ad here

Web Premium



Get Qwest High Speed Internet



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: ( Note: Brackets around Kimili code removed because of WordPress. )

kml_flashembed movie="/flash/471_FlashVars.swf"height="100" width="200" fvars="var1=One&var2=Two"

If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

6 Responses to “Passing varibles to Flash via FlashVars”


comment number 1 by: Matthew

Thanks for making the code easy. And reminding me about that damn java comma!


[...] Read more [...]

comment number 3 by: Terence

It’s pretty easy to write a your own shortcode since WordPress 2.5. I searched though the plugin directory for flash embeding plugin, but turn out that it can be easily written in less that 20 minutes.

Terences last blog post..Flash and Silverlight: 3D Image Rotation

comment number 4 by: brent

not sure I understand your kimili example, there's no kimili code above that I can see, am I missing something? I viewed the source but that only shows what kimili generated right?

brent

@

mimoYmima.com

comment number 5 by: polyGeek

@brent, sorry about that. WordPress messed up my code when I submitted the post. I added it back – minus the brackets this time. Hope that helps.

comment number 6 by: Pete Curnutt

Hi Poly,

Thanks for sharing this tags coding with us. It'll help be lot in my project.

Keep sharing the good codes.

   Welcome back (Change)

Leave a Reply

comment feed RSS   subscribe to this comment thread

Recent Posts

   



polyGeek.com

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

Better Tag Cloud