views:

3190

answers:

3

It exists too many method for embedding flash in html, which way is the best? Requirements are:

  • Cross-browser support
  • Support for alternative content (if flash is not supported by the browser)
  • Possibility to require a specific version of the flash player

I have been reading about SWFobject, anyone used/tested?

+12  A: 

In a project I work on we use SWFobject which works like a charm, it allows you to check for a specific version and also display alternative content if flash is not supported.

var fn = function() {
 if(swfobject.hasFlashPlayerVersion("9.0.115"))
 {
  var att = { data:"flash.swf", width:"y", height:"x" };
  var par = { menu: "false", flashvars: "" };
  signUp = swfobject.createSWF(att, par);
 }
}
swfobject.addDomLoadEvent(fn);
martinlund
+1  A: 

Yeah, we use that for flash detection on our site and it works extremely well, avoiding the problem that you normally have to click to activate flash controls in IE. We've tested it in many browsers (different versions of IE, Firefox, Opera, Safari, Chrome) on multiple operating systems (Windows XP, Windows Vista, Windows Server 2003, Windows Server 2008, Mac OSX, Linux) and once you've got it set up correctly it works perfectly on all.

Greg Beech
+2  A: 

I would highly recommend using flashembed. It has support for everything you need and more, without being that complicated to use. It was originally developed for embedding flowplayer, which I can also recommend, but it works for any flash file.

An example of how I use it:

flashembed("frontPageFlash",
    {
        src: "img/flash/FrontPage.swf",
        width: "480",
        height: "600",
        bgcolor: "#ebebeb",
        version: [9,0],
        expressInstall:'scripts/expressinstall.swf'
    },{
        head1: "<%= frontPageFlashHead1 %>",
        head2: "<%= frontPageFlashHead2 %>",
        pitch1: "<%= frontPageFlashPitch1 %>",
        pitch2: "<%= frontPageFlashPitch2 %>"
    }
);

And where it is embedded I simply put:

<div id="frontPageFlash"></div>
Gieron