aamiri
aamiri

Reputation: 2440

SetVariable works in FireFox but not Internet Explorer?

I am building a video player web-app that uses flash for playback and jquery/javascript for UI. By design of the person who wrote the flash component I need to use setVariable to communicate between the javascript and the flash player. I've read all over the internet that a lot of people have had problems gettin setVariable to work in FireFox. I designed my app in firefox because i wanted to use firebug to help me in development. Now that the whole thing has been built, i find that setVariable is not working in IE. The error i get is: Object doesn't support property or method 'SetVariable';

Here's a bit of the pertinent code:

I construct my html through javascript, so this is how I construct the player:

var player =
'<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,16,0" width="1" height="1" >' +
'<param name="movie" value="/flash/Player.swf?server='+server+'">' +
'<param name="quality" value="high">' +
'<param name="play" value="true">' +
'<param name="LOOP" value="false">' +
'<param name="wmode" value="transparent">' +
'<embed wmode="transparent" src="/flash/Player.swf?server='+server+'" width="1" height="1" play="true" loop="false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>' +
'</object>'; 

after I append this to the page I call set variable:

that.player.SetVariable('track',trackNo);

Any advice would be appreciated. I know external interface is the preferred method of cross js flash communique, but I don't have access to the flash file, and can't change it, so please only give solutions using setVariable. Thank You.

Upvotes: 0

Views: 2512

Answers (1)

Dennis Jaamann
Dennis Jaamann

Reputation: 3565

What you need to know is that the html code you have to write to embed an swf file is different for some browsers.

Firefox and other Netscape based browsers use <object> tags while IE uses <embed> tags.

You can use SWFObject to embed the swf on your page.
It is a single-file, open source library that will handle all cross browser flash embedding quirks for you.
It even comes with a handy generator that will assist you in making the correct embedding code for use with the library.

You can then retrieve the swf by id from the DOM tree and set your variable on the correct object.

Also, you should check if you can use FlashVars instead of SetVariable()

Cheers

Upvotes: 2

Related Questions