Question

There are 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, has anyone used it/tested?

Was it helpful?

Solution

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);

OTHER TIPS

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>

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.

I use SWFObject myself, in combination with the <embed> and <object> tags. The reason I include the HTML embeds, is that SWFObject and flashembed rely on Javascript to update the DOM. Not every user who has Flash installed also has Javascript enabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top