# Rails Plugin for swfobject? - swf\_fu

**URL:** <https://www.ruby-forum.com/t/rails-plugin-for-swfobject-swf-fu/172972>\
**Category:** Rails\
**Created:** [July 30, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/rails-plugin-for-swfobject-swf-fu/172972 "2009-07-30T17:39:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [July 30, 2009, 5:39pm UTC](https://www.ruby-forum.com/t/rails-plugin-for-swfobject-swf-fu/172972/1 "2009-07-30T17:39:38Z")

</div>

Hi all,

I’ve been using a plugin called swf\_fu which seemed fairly easy to  
implement for adding flash content to my rails app. However, I’m trying  
to pass a variable to my flash through rails and have the flash content  
pick it up.

The variable is already retrieved in an earlier call to the database so  
I don’t believe it’s any type of authentication string issue. Here’s  
two examples:

\<%= swf\_tag “victory.swf”, :size =\> “250x75”, :div\_id =\> “flbars”,  
:flashvars =\> “victory\_id=#{@virtuals\_victory}”, :parameters =\> {:wmode  
=\> ‘transparent’} %\>

OR

\<%= swf\_tag “victory.swf”, :size =\> “250x75”, :div\_id =\> “flbars”,  
:flashvars =\> {:victory\_id =\> @virtuals\_victory}, :parameters =\> {:wmode  
=\> ‘transparent’} %\>

As a generic test, I’m passing the following value with  
@virtuals\_victory by doing @virtuals\_victory = 76.

In my flash I’m doing:

onSelfEvent (load) {  
victoryID = this.loaderInfo.parameters.victory\_id;  
}

… which is going to pull the victory\_id value sent to it through  
swfobject’s flashvars.

When I pull it up, it doesn’t show the value and the source shows the  
following:

swfobject.embedSWF(“/swfs/victory.swf?1248962132”,“flbars”,“250”,“75”,“7”,“/swfs/expressInstall.swf?1248568039”,{“victory\_id”:“76”,“id”:“victory”},{“wmode”:“transparent”},{“id”:“victory”})

As you can see, right after the expressInstall, the flashvars hash is  
showing “victory\_id”:“76” in the first case and in the second case it  
shows “victory\_id”:76.

Does anyone have an idea of why flash isn’t retrieving the flashvars  
with swfobject? I’ve checked the readme of the plugin and it says:

=== Options

- :id - the DOM +id+ of the flash +object+ element that is used  
to contain the Flash object; defaults to the name of the swf in +source+
- :width, :height - the width & height of the Flash object.  
Defaults to “100%”. These could also specified using :size
- :size - the size of the Flash object, in the form “400x300”.
- :mode - Either :dynamic (default) or :static. Refer to  
SWFObject’s  
doc[[GitHub - swfobject/swfobject: An open source Javascript framework for detecting the Adobe Flash Player plugin and embedding Flash (swf) files.](http://code.google.com/p/swfobject/wiki/documentation#Should_I_use_the_static_or_dynamic_publishing_method?)]
- :flashvars - a Hash of variables that are passed to the swf.  
Can also be a string like “foo=bar&hello=world”. Defaults to  
{:id =\> the DOM id}
- :parameters - a Hash of configuration parameters for the swf.  
See Adobe’s  
doc[[http://kb.adobe.com/selfservice/viewContent.do?externalId=tn\_12701#optional](http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_12701#optional)]
- :alt - HTML text that is displayed when the Flash player is  
not available. Defaults to a “Get Flash” image pointing to Adobe Flash’s  
installation page. This can also be specified as a block (see embedding  
section)
- :flash\_version - the version of the Flash player that is  
required (e.g. “7” (default) or “8.1.0”)
- :auto\_install - a swf file that will upgrade flash player if  
needed (defaults to “expressInstall” which was installed by swf\_fu)
- :javascript\_class - specify a javascript class (e.g.  
“MyFlash”) for your flash object. If it exists, the initialize method  
will be called.
- :initialize - arguments to pass to the initialization method  
of your javascript class.
- :div\_id - the DOM +id+ of the containing div itself. Defaults  
to “#{option[:id]}”\_div
- :switch\_off\_auto\_hide\_show - switch off SWFObject’s default  
hide/show behavior. SWFObject temporarily hides your SWF or alternative  
content until the library has decided which content to display. Defaults  
to nil.

So, at this point I’m not understanding why I can’t get this to work.  
I’ve also tried doing:

skip\_before\_filter :verify\_authenticity\_token

… on the controller processing the variable …

Any advice on this issue?

---

<div class="post-metadata">

**Author:** ![elricstorm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/da6949/32.png) [@elricstorm](https://www.ruby-forum.com/u/elricstorm)\
**Post date:** [July 30, 2009, 7:59pm UTC](https://www.ruby-forum.com/t/rails-plugin-for-swfobject-swf-fu/172972/2 "2009-07-30T19:59:28Z")

</div>

> onSelfEvent (load) {  
> victoryID = this.loaderInfo.parameters.victory\_id;  
> }

Everything was fine. The issue was actually in the flash software  
itself. I use both macromedia and swishmax and swishmax2 and sometimes  
I forget that each passes variables a bit differently.

The above should have appeared as:

onSelfEvent (load) {  
victoryID = victory\_id;  
}

Thanks.
