In a previous post I was writing about a fix to remove the Press Spacebar or Enter to activate or use this control message. But it also made a mess out of a flash file I was trying to use. After a lot of looking into the source code (Flex) and trying to understand what happened, I found a solution.

First of all, you will find a lot of web pages advocating using a parameter called flashVars for sending parameters to Flash applications. Then you would use Application.application.parameters to get the variables URLEncoded in flashVars. That works in most cases, but not when:
a. you used an IE fix for the annoying message
b. you have in the movie and/or src parameters an url that has parameters. (like when you would get the SWF file out from an HttpHandler, for example)

The solution is to put all the variables you would put in the flashVars in the url of the movie or src parameters.

So, instead of :
<param name='movie' value='test.swf' />
<param name='flashVars' value='a=%27test%27&b=12' />

use
<param name='movie' value='test.swf?a=%27test%27&b=12' />

Don't forget to UrlEncode the values.

But why does this happen? Apparently, the problem is that after setting the innerHTML property the FlashVars param element has an empty value. I tried to fix the javascript to 1. get the value of FlashVars 2. do the fix 3. replace the empty FlashVars value with the saved value. It did not work! Even by javascript, after finding the param element with the name of FlashVars and an empty value, I could not set the value of the element. It probably has to do with the IE "fix". Something must clear the FlashVars when being set from anything else but from source.

Comments

Bruno

Thaks for your solution. Very simple and very efficient. Helped me a lot

Bruno

Elar

Thanx a lot. The IE fix was only way to restart hidden flash playing from beginning after setting it visible on IE 7 &amp; 8. Saved me a great headache to find solution for flashvars problem :)

Elar

Anonymous

To those suggesting SWFObject, great as that is, there are situations where it can&#39;t reach - for example if you need to save the contents of a DIV via innerHTML, or if you&#39;re duplicating an HTML fragment where the contents are unknown.

Anonymous

Anonymous

You rocks !! i search it about 4 hours. You saved my life. Thanks a lot.[Fuck IE]

Anonymous

nithon

just wanted to say thanks that was just what i was lookig for :)

nithon

Anonymous

totally agreed...swfobject can be cumbersome to work with when this little gem helps out greatly

Anonymous

Anonymous

Don&#39;t listen to the tudor idiot. This code just made my day a little brighter! Solving these freak situations in IE is a headache. Thank you for your help!

Anonymous

Siderite

Because SWFObject, as lovely and Javascript guru as it sounds, does the exact same thing. It creates html then fills some innerHTML property. What would be beyond stupid would be to recreate the HTML in Javascript when I already have it from my codebehind.

Siderite

Tudor

This is beyond stupid! Why don&#39;t you use http://blog.deconcept.com/swfobject/ (SWFObject), like everybody else?

Tudor

Post a comment