Skip to main content
skalamichal
Known Participant
October 30, 2006
Question

GetVariable doesn't work in Firefox/Opera

  • October 30, 2006
  • 1 reply
  • 924 views
Hi,

I'm trying to get flash object variable via Javascript. But the code doesn't work for Firefox/Opera but is working well for IE. Here is an example of JS that I have used:

var movie = window.document.flashMovie;
movie.GetVariable("/obj:variable");
or
movie.GetVariable("_root.obj.variable");
or
movie.GetVariable("obj.variable");

None of them is working.

Thanks for any help.
Michal
This topic has been closed for replies.

1 reply

October 30, 2006
var bolIsIE = (navigator.appName.indexOf("Microsoft") != -1);
var objFlash;

objFlash = (bolIsIE) ? window["yourFlashId"] : document.embeds["yourFlashId"];
// objFlash.GetVariable....

In Gecko browser, to get a Flash object you must use document.embeds which is an array of all the Flash object in the page. Don't forget that IE use window and Gecko work with document.
skalamichal
Known Participant
October 30, 2006
Thanks, but this isn't an issue.

The window.document.flashMovie will return the correct flash object/embed flash movie.
The issue is that the GetVariable method wont return the object variable. When you try to get an simple variable that is in the _root timeline, it will return the value. Example:
movie.GetVariable(_url) will return the url of the flash movie without any problem.

But when you create an ActionScript class with userName property and then you will create the instance of it in the _root, you should be able to get it's value. Example:
Flash:
var obj = new SomeClass();
obj.userName = "peter";
JavaScript:
movie.GetVariable("/obj:userName");
or
movie.GetVariable("obj.userName");

This will return Peter for IE and null for Forefox/Opera.
The same when you use the document.embeds[..].
skalamichal
Known Participant
October 31, 2006
I wonder if anybody can help me with this.
I just need to know, if this is an issue in flash player plugin ? Or it shouldn't work in IE too ?

Thanks again for any help any response.

Michal