ok, I spent a good bit of time chasing this one down. the conclusion I’ve come to is that there’s a bug in the “debug” version of the Flash Player 7,0,19,0 that makes it impossible to use SetVariable to communicate between JavaScript and Flash.
With Flash Player 7,0,19,0 _debug_
I can get SetVariable to work in Internet Explorer 6.0..
I can get SetVariable to work in Netscape 7.1
I can’t get SetVariable to work with Firefox 1.0
a couple of other folks who wrestled with this..
http://www.markme.com/teammmflash/archives/005316.cfm (last comment)
http://www.flashsupport.com/forum/topic.asp?TOPIC_ID=1133 (post from dj_roeeze - note that he found that getting a different version of the FP fixed it.. )
Once I un-install the debug Player and install the standard Player my SetVariable code works just fine in IE, Netscape, or Firefox 1.0. Wee..
If this isn’t the case.. and you are able to get SetVariable to work with the debug version of the Flash Player while using Firefox 1.0.. please comment.
((note.. see my comment from April 26th for a solution))
07 Feb 2005 at 10:01 am | #
I don't know specifically of the debugging player version with LiveConnect communication (and I don't have the chance to fully search at the moment), but I'd like to make sure I'm understanding the symptom correctly, and I'm not yet sure which of the following two paths is being described here:
a) Having the browser set a variable in the SWF is the only Player JavaScript API command which fails, and all other Player JavaScript API commands work normally; or
b) Setting a variable was the only command tested in the player's JavaScript API, and it's still indeterminate whether it's the one action, or all actions, which fail.
And I'm making the assumption that this is the same Firefox installation used in both tests, in the same configuration (particularly Java ability), with the same HTML. But if this reading is incorrect, then other possibilities remain open.
tx,
jd/mm
07 Feb 2005 at 10:29 am | #
I'll take "b".. all I've tested is SetVariable.. this is on the same system, same Firefox, etc. All I did was switch to the standard Player and it worked. Switch back to the debug Player and it fails.
07 Feb 2005 at 11:40 pm | #
ok.. total weirdness here.. on my XP box I still have the problem where SetVariable doesn't work with the debug version of the Flash Player but does work with the standard player. With my Win2k box it works with either the debug player or the standard player. I've heard from one person who has XP and can use either the debug player or the standard player. So whatever is causing the problem is specific to my machine (and a few other people have the same problem based on message board threads).. mileage may vary.
Who knows what caused this... I'm moving on to other things.
09 Feb 2005 at 08:46 am | #
fwiw, testing other LiveConnect communications in that configuration can still be helpful in determining whether the problem is in (a) the communication path or (b) that individual message.
jd
26 Feb 2005 at 09:05 am | #
Hi there, I visited this page via Google: I had exactly the same problem and was trying to fix it. SetVariable would not work in Firefox. Well, I think I fixed it, hope it works for you guys as well. You should check the browser and adjust the code for Firefox-visitors. Note that it has not been tested for 100%, but it looks like this is working at the moment. I will be testing some more. When I can give some more info I will post it as well.
//for use in IE & Opera:
var swf_top = window.parent.document.top_title;
//for use in Firefox:
var swf_top = window.parent.document.embeds[0];
//After declaring swf_top, call it like:
swf_top.SetVariable("current_main", mi_id);
28 Feb 2005 at 12:42 am | #
var swf_top = window.parent.document.embeds[0];
that doesnt do it either. Until now I tried a lot but no success.
In IE it runs w.o. problems even if you dont use that rat's tail: window.parent.document.top_title.setVariable...
top_title.setVariable... is enough
guess that firefox is simply junk.
25 Apr 2005 at 07:33 am | #
Well, it works in this page in FireFox:
http://www.permadi.com/tutorial/flashjscommand/
but not on this page:
http://www.flash-here.com/tutorials/flash_from_js1.html
As far as I can see; only minor differences int he code (i.e. upper- lower case issues, etc) Or am I blind?
26 Apr 2005 at 08:54 pm | #
I put something together that might help clear it up? http://oddhammer.com/tutorials/firefox_setvariable/ I also got it working with Opera. Note that the permadi example breaks in Opera..
17 May 2005 at 04:13 am | #
it seems coming only from 'swliveconnect' char case, it appears FireFox need lowercase...
07 Jun 2005 at 09:26 pm | #
You might also take a look at the Flash/JavaScript Integration Kit from Macromedia: http://weblogs.macromedia.com/flashjavascript/
21 Aug 2005 at 08:37 pm | #
Yes I had this problem too, it took me about 2 days of trial and error to resolve and I would have believed that Firefox simply didn't support SendVariable if I hadn't found the example below, where it did work.
http://www.permadi.com/tutorial/flashjscommand/
(((edited to add - please note my earlier comment about the permadi example and opera - mike)))
I did resolve the probelm in the end, the solution in my case was removing the name variable in the object tag. Having an id and a name in the object tag when the name is duplicated in the embed tag (for firefox) caused the problem.
(((edited to add - there's a Macromedia Technote on this too - mike)))
Below is the described code. Can been seen in action at [url=http://www.ausbuild.com.au]http://www.ausbuild.com.au[/url]
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" id="SubMenu" width=100% height=100%>
<!-- I had name="SubMenu" in the above tag -->
<param name="movie" value="images/Flash/SubMenu2.swf">
<param name=quality value=high>
<param name=wmode value=transparent>
<param name="allowscriptaccess" value="samedomain">
<embed src="images/Flash/SubMenu2.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width=100% height=100% name="SubMenu" swliveconnect="true" allowScriptAccess="samedomain" wmode="transparent">
</embed>
</object>
28 Sep 2005 at 11:25 am | #
Nothing of the above it seems!
Is Firefox bug and happens when Firefox and flash player are installed in wrong or "odd" order so some files are confused in installation directories. Macromedia fixed it on their end with player version 8.
See
https://bugzilla.mozilla.org/show_bug.cgi?id=233533
for more...
Cheers!
14 Oct 2005 at 05:39 am | #
A little tricky thing . . . .
I had this problem and searched for an hour. The solution was simple for me : the SetVariable method takes 2 CAPITALS !!
Because Internet Explorer don't care if you forget one but Firefox is more precise.
Hope it helps
21 Dec 2005 at 02:23 am | #
I just battled with the SetVariable on Firefox and found out why it didn't work: I had the same ID in the OBJECT-Tag and in the EMBED-Tag within the OBJECT-Tag. document.getElementId then returned the OBJECT-DOM-Object and not the EMBED-Object, thus no SetVariable.
I fixed it by adding a _mozilla postfix to the ID and checking for the xxx_mozilla first with getElementById, f.ex ID=foo:
if(document.getElementById('foo_mozilla') != undefined) myObject=document.getElementById('foo_mozilla') else myObject=document.getElementById('foo');
myObject.SetVariable(....
Hope this helps someone..
24 Feb 2006 at 12:58 pm | #
Keep posting, Thanks a lot.
30 May 2006 at 10:16 pm | #
Tero's solution worked for me. Publishing to Flash 8 didn't help, BTW. Thanks, Tero.
19 Jun 2006 at 05:27 pm | #
NICE NICE NICE - thinking outside the box. You just saved me a buch of heartache.
If you want a nice Captivate controller built in javascript and NOW crossbrowser - email me at the above address.
21 Jan 2007 at 04:28 pm | #
You have NO idea how glad I am to have found this thread...
Tero's solution works great but you do need to make sure you have the two capitals as Jalil mentioned.
I can just imagine the HOURS of anguish this would have caused me!
Cheers guys!
09 Apr 2007 at 11:44 am | #
I just tried Tero's solution, and it doesn't work for me in flash player 9, firefox 1.5. myObject.id is definitely being set to foo_mozilla. yet when I call myObject.SetVariable I get the familiar myObject.SetVariable is not a function. Weird.
21 May 2007 at 03:23 pm | #
Has anyone found a fix for this? Currently experiencing the same issue as mike p above me. Flash Player 9, FF 2.0, still getting the SetVariable is not a function.
24 Aug 2007 at 06:41 am | #
This code worked for me. IT worked on IE, firefox and opera
if (navigator.appName.indexOf("Microsoft Internet")==-1){
if (document.embeds && document.embeds[“YourFlashObjectName”]){
document.embeds[“YourFlashObjectName”].SetVariable("_Attribute",value);
}
} else if (navigator.appName.indexOf("Microsoft Internet")!=-1){
document.getElementById(“YourFlashObjectName”). SetVariable("_Attribute",value);
}
Regards,
Lakshmi
10 Oct 2007 at 06:19 pm | #
Thank you Lakshmi!!!!
30 Jun 2008 at 04:10 am | #
An small addition:
This code really works for IE 6+7, Firefox 2+3 (Firefox 1 and Opera not tested) as others didn't work for me:
(inspired by http://www.permadi.com/tutorial/flashjscommand/)
function getFlashMovieObject(movieName)
{
if(document.embeds[movieName])
return document.embeds[movieName];
if(window.document[movieName])
return window.document[movieName];
if(window[movieName])
return window[movieName];
if(document[movieName])
return document[movieName];
return null;
}
Please note the order of the if-statements; in a different order it also didn't work for me - so just copy and relax
I hope this will eventually end the searches for this very annoying behavior!
Warappa